|
@@ -56,16 +56,7 @@ namespace Terra.Arbitrator.GUI
|
|
|
|
|
|
public void OnEnable()
|
|
|
{
|
|
|
- if (SessionState.GetBool(BetterGitStatePersistence.ResetQueueKey, false))
|
|
|
- {
|
|
|
- SessionState.EraseString(BetterGitStatePersistence.ResetQueueKey);
|
|
|
- InfoMessage = "Multi-file reset complete. Pulling again to confirm...";
|
|
|
- Pull();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- Refresh();
|
|
|
- }
|
|
|
+ Refresh();
|
|
|
}
|
|
|
|
|
|
public void Refresh()
|
|
@@ -406,57 +397,35 @@ namespace Terra.Arbitrator.GUI
|
|
|
|
|
|
private void ResetMultipleFiles(List<string> filePaths)
|
|
|
{
|
|
|
- var hasScripts = filePaths.Any(p => p.EndsWith(".cs", StringComparison.OrdinalIgnoreCase));
|
|
|
-
|
|
|
- if (hasScripts)
|
|
|
- {
|
|
|
- InfoMessage = $"Starting reset for {filePaths.Count} file(s)... This may trigger script compilation.";
|
|
|
- _requestRepaint?.Invoke();
|
|
|
- SessionState.SetString("BetterGit.ResetQueue", string.Join(";", filePaths));
|
|
|
- EditorApplication.delayCall += BetterGitStatePersistence.ContinueInterruptedReset;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- StartOperation($"Resetting {filePaths.Count} file(s)...");
|
|
|
+ EditorApplication.LockReloadAssemblies();
|
|
|
+ StartOperation($"Resetting {filePaths.Count} file(s)...");
|
|
|
|
|
|
- IPromise<string> promiseChain = new Promise<string>((resolve, _) => resolve(""));
|
|
|
+ IPromise<string> promiseChain = new Promise<string>((resolve, _) => resolve(""));
|
|
|
|
|
|
- foreach (var path in filePaths)
|
|
|
+ foreach (var path in filePaths)
|
|
|
+ {
|
|
|
+ promiseChain = promiseChain.Then(_ =>
|
|
|
{
|
|
|
- promiseChain = promiseChain.Then(_ => {
|
|
|
- var change = GitService.GetChangeForFile(path);
|
|
|
- return change != null ? GitService.ResetFileChanges(change) : new Promise<string>((res, _) => res(""));
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- promiseChain
|
|
|
- .Then(successMsg => {
|
|
|
- InfoMessage = $"Successfully reset {filePaths.Count} file(s).";
|
|
|
- Refresh();
|
|
|
- })
|
|
|
- .Catch(ex => {
|
|
|
- HandleOperationError(ex);
|
|
|
- FinishOperation();
|
|
|
- });
|
|
|
+ var change = GitService.GetChangeForFile(path);
|
|
|
+ return change != null ? GitService.ResetFileChanges(change) : new Promise<string>((res, _) => res(""));
|
|
|
+ });
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- public void ForcePull()
|
|
|
- {
|
|
|
- StartOperation("Attempting to pull and create conflicts...");
|
|
|
-
|
|
|
- EditorApplication.LockReloadAssemblies();
|
|
|
- GitService.ForcePull()
|
|
|
+
|
|
|
+ promiseChain
|
|
|
.Then(_ =>
|
|
|
{
|
|
|
- InfoMessage = "Pull resulted in conflicts. Please resolve them below.";
|
|
|
+ InfoMessage = $"Successfully reset {filePaths.Count} file(s).";
|
|
|
+ Refresh();
|
|
|
+ })
|
|
|
+ .Catch(ex =>
|
|
|
+ {
|
|
|
+ HandleOperationError(ex);
|
|
|
+ FinishOperation();
|
|
|
})
|
|
|
- .Catch(HandleOperationError)
|
|
|
.Finally(() =>
|
|
|
{
|
|
|
EditorApplication.UnlockReloadAssemblies();
|
|
|
AssetDatabase.Refresh();
|
|
|
- Refresh();
|
|
|
});
|
|
|
}
|
|
|
|