Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit c9b040f

Browse files
committed
Merge master into fixes/task-field-cleanup
2 parents 373e2a1 + 5c1652c commit c9b040f

22 files changed

+108
-89
lines changed

src/GitHub.Api/Application/ApplicationManagerBase.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ abstract class ApplicationManagerBase : IApplicationManager
1111
{
1212
protected static ILogging Logger { get; } = Logging.GetLogger<IApplicationManager>();
1313

14-
private IEnvironment environment;
1514
private RepositoryManager repositoryManager;
1615

1716
public ApplicationManagerBase(SynchronizationContext synchronizationContext)

src/GitHub.Api/Authentication/ICredentialManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ interface ICredential : IDisposable
1414
interface ICredentialManager
1515
{
1616
Task<ICredential> Load(UriString host);
17-
Task Save(ICredential credential);
17+
Task Save(ICredential cred);
1818
Task Delete(UriString host);
1919
bool HasCredentials();
2020
ICredential CachedCredentials { get; }

src/GitHub.Api/Authentication/LoginManager.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public async Task<LoginResultData> Login(
9494
if (e is TwoFactorRequiredException)
9595
{
9696
result = LoginResultCodes.CodeRequired;
97-
logger.Debug("2FA TwoFactorAuthorizationException: {0} {1}", LoginResultCodes.CodeRequired, e.Message);
97+
logger.Trace("2FA TwoFactorAuthorizationException: {0} {1}", LoginResultCodes.CodeRequired, e.Message);
9898
}
9999
else
100100
{
@@ -166,21 +166,21 @@ public async Task<LoginResultData> ContinueLogin(LoginResultData loginResultData
166166
}
167167
catch (TwoFactorAuthorizationException e)
168168
{
169-
logger.Debug(e, "2FA TwoFactorAuthorizationException: {0} {1}", LoginResultCodes.CodeFailed, e.Message);
169+
logger.Trace(e, "2FA TwoFactorAuthorizationException: {0} {1}", LoginResultCodes.CodeFailed, e.Message);
170170

171171
return new LoginResultData(LoginResultCodes.CodeFailed, Localization.Wrong2faCode, client, host, newAuth);
172172
}
173173
catch (ApiValidationException e)
174174
{
175-
logger.Debug(e, "2FA ApiValidationException: {0}", e.Message);
175+
logger.Trace(e, "2FA ApiValidationException: {0}", e.Message);
176176

177177
var message = e.ApiError.FirstErrorMessageSafe();
178178
await keychain.Clear(host, false);
179179
return new LoginResultData(LoginResultCodes.Failed, message, host);
180180
}
181181
catch (Exception e)
182182
{
183-
logger.Debug(e, "Exception: {0}", e.Message);
183+
logger.Trace(e, "Exception: {0}", e.Message);
184184

185185
await keychain.Clear(host, false);
186186
return new LoginResultData(LoginResultCodes.Failed, e.Message, host);

src/GitHub.Api/Events/RepositoryWatcher.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ public void Start()
7171
{
7272
if (disableNative)
7373
{
74-
Logger.Debug("Native interface is disabled");
74+
Logger.Trace("Native interface is disabled");
7575
return;
7676
}
7777

7878
if (nativeInterface == null)
7979
{
8080
Logger.Warning("NativeInterface is null");
81-
throw new Exception("Not initialized");
81+
throw new InvalidOperationException("NativeInterface is null");
8282
}
8383

8484
running = true;

src/GitHub.Api/Git/GitCredentialManager.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ public async Task<ICredential> Load(UriString host)
9797
return credential;
9898
}
9999

100-
public async Task Save(ICredential credential)
100+
public async Task Save(ICredential cred)
101101
{
102-
Logger.Trace("Save: {0}", credential.Host);
102+
this.credential = cred;
103103

104-
this.credential = credential;
104+
Logger.Trace("Save: {0}", credential.Host);
105105

106106
if (!await LoadCredentialHelper())
107107
return;

src/GitHub.Api/Git/GitStatusEntry.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ namespace GitHub.Unity
55
[Serializable]
66
struct GitStatusEntry
77
{
8-
public readonly string Path;
9-
public readonly string FullPath;
10-
public readonly string ProjectPath;
11-
public readonly string OriginalPath;
12-
public readonly GitFileStatus Status;
13-
public readonly bool Staged;
8+
public string Path;
9+
public string FullPath;
10+
public string ProjectPath;
11+
public string OriginalPath;
12+
public GitFileStatus Status;
13+
public bool Staged;
1414

1515
public GitStatusEntry(string path, string fullPath, string projectPath,
1616
GitFileStatus status,

src/GitHub.Api/IO/FileSystem.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,19 @@ public FileSystem()
1414
{
1515
}
1616

17-
public FileSystem(string currentDirectory)
17+
/// <summary>
18+
/// Initialize the filesystem object with the path passed in set as the current directory
19+
/// </summary>
20+
/// <param name="directory">Current directory</param>
21+
public FileSystem(string directory)
1822
{
19-
this.currentDirectory = currentDirectory;
23+
this.currentDirectory = directory;
2024
}
2125

22-
public void SetCurrentDirectory(string currentDirectory)
26+
public void SetCurrentDirectory(string directory)
2327
{
24-
Debug.Assert(Path.IsPathRooted(currentDirectory));
25-
this.currentDirectory = currentDirectory;
28+
Debug.Assert(Path.IsPathRooted(directory));
29+
this.currentDirectory = directory;
2630
}
2731

2832
public bool FileExists(string filename)

src/GitHub.Api/IO/FileSystemHelpers.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@ static class FileSystemHelpers
77
{
88
public static string FindCommonPath(IEnumerable<string> paths)
99
{
10-
var pathsArray = paths.Where(s => s != null).Select(s => s.ToNPath().Parent).ToArray();
11-
var maxDepth = pathsArray.Max(path => path.Depth);
12-
var deepestPath = pathsArray.First(path => path.Depth == maxDepth);
10+
var parentPaths = paths.Where(s => !string.IsNullOrEmpty(s)).Select(s => s.ToNPath().Parent);
11+
if (!parentPaths.Any())
12+
return null;
13+
14+
var parentsArray = parentPaths.ToArray();
15+
var maxDepth = parentsArray.Max(path => path.Depth);
16+
var deepestPath = parentsArray.First(path => path.Depth == maxDepth);
1317

1418
var commonParent = deepestPath;
15-
foreach (var path in pathsArray)
19+
foreach (var path in parentsArray)
1620
{
1721
var cp = path.Elements.Any() ? commonParent.GetCommonParent(path) : null;
1822
if (cp != null)

src/GitHub.Api/NewTaskSystem/ConcurrentExclusiveInterleave.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,8 @@ protected override IEnumerable<Task> GetScheduledTasks()
391391
/// <param name="task">The task to be executed.</param>
392392
internal void ExecuteTask(Task task)
393393
{
394-
var processingTaskOnCurrentThread = this.processingTaskOnCurrentThread.Value;
395-
if (!processingTaskOnCurrentThread) this.processingTaskOnCurrentThread.Value = true;
394+
var isProcessingTaskOnCurrentThread = this.processingTaskOnCurrentThread.Value;
395+
if (!isProcessingTaskOnCurrentThread) this.processingTaskOnCurrentThread.Value = true;
396396
//try
397397
//{
398398
TryExecuteTask(task);
@@ -403,7 +403,7 @@ internal void ExecuteTask(Task task)
403403
// throw;
404404
//}
405405

406-
if (!processingTaskOnCurrentThread) this.processingTaskOnCurrentThread.Value = false;
406+
if (!isProcessingTaskOnCurrentThread) this.processingTaskOnCurrentThread.Value = false;
407407
}
408408

409409
/// <summary>Gets the maximum concurrency level this scheduler is able to support.</summary>

src/GitHub.Api/NewTaskSystem/TaskBase.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ interface ITask : IAsyncResult
1010
ITask Catch(Action<Exception> handler);
1111
ITask Catch(Func<Exception, bool> handler);
1212
ITask Finally(Action handler);
13-
ITask Finally(Action<bool, Exception> continuation, TaskAffinity affinity = TaskAffinity.Concurrent);
13+
ITask Finally(Action<bool, Exception> actionToContinueWith, TaskAffinity affinity = TaskAffinity.Concurrent);
1414
ITask Defer<T>(Func<T, Task> continueWith, TaskAffinity affinity = TaskAffinity.Concurrent, bool always = false);
1515
ITask Start();
1616
ITask Start(TaskScheduler scheduler);
@@ -157,22 +157,22 @@ public ITask Finally(Action handler)
157157
return this;
158158
}
159159

160-
public ITask Finally(Action<bool, Exception> continuation, TaskAffinity affinity = TaskAffinity.Concurrent)
160+
public ITask Finally(Action<bool, Exception> actionToContinueWith, TaskAffinity affinity = TaskAffinity.Concurrent)
161161
{
162-
Guard.ArgumentNotNull(continuation, "continuation");
163-
var ret = Then(new ActionTask(Token, continuation) { Affinity = affinity, Name = "Finally" }, true);
162+
Guard.ArgumentNotNull(actionToContinueWith, nameof(actionToContinueWith));
163+
var ret = Then(new ActionTask(Token, actionToContinueWith) { Affinity = affinity, Name = "Finally" }, true);
164164
DependsOn?.SetFaultHandler(ret);
165165
ret.ContinuationIsFinally = true;
166166
return ret;
167167
}
168168

169-
internal virtual ITask Finally<T>(T continuation)
169+
internal virtual ITask Finally<T>(T taskToContinueWith)
170170
where T : TaskBase
171171
{
172-
Guard.ArgumentNotNull(continuation, "continuation");
172+
Guard.ArgumentNotNull(taskToContinueWith, nameof(taskToContinueWith));
173+
continuation = (TaskBase)(object)taskToContinueWith;
174+
continuationAlways = true;
173175
continuation.SetDependsOn(this);
174-
this.continuation = (TaskBase)(object)continuation;
175-
this.continuationAlways = true;
176176
DependsOn?.SetFaultHandler((TaskBase)(object)continuation);
177177
return continuation;
178178
}
@@ -413,7 +413,6 @@ public TaskBase(CancellationToken token)
413413
public TaskBase(Task<TResult> task)
414414
: base()
415415
{
416-
var scheduler = TaskManager.GetScheduler(Affinity);
417416
Task = new Task<TResult>(t =>
418417
{
419418
TResult ret = default(TResult);

0 commit comments

Comments
 (0)