private void PostprocessStage(string[] paths) { if (repository == null || !IsValidRepo) { return; } if (prefs.GetBool(UnityEditorGitPrefs.DisablePostprocess)) { return; } string[] pathsFinal = paths.Where(a => !IsEmptyFolder(a)).SelectMany(GetPathWithMeta).ToArray(); if (pathsFinal.Length > 0) { bool autoStage = gitSettings != null && gitSettings.AutoStage; if (Threading.IsFlagSet(GitSettingsJson.ThreadingType.Stage)) { if (autoStage) { AsyncStage(pathsFinal); } else { MarkDirty(pathsFinal); } } else { if (autoStage) { GitCommands.Stage(repository, pathsFinal); } MarkDirty(pathsFinal); } } }
public void AutoUnstage(string[] paths) { if (Threading.IsFlagSet(GitSettingsJson.ThreadingType.Unstage)) { AsyncUnstage(paths); } else { GitCommands.Unstage(repository, paths); MarkDirty(paths); } }
public void AutoStage(params string[] localPaths) { if (Threading.IsFlagSet(GitSettingsJson.ThreadingType.Stage)) { AsyncStage(localPaths); } else { GitCommands.Stage(repository, localPaths); MarkDirtyAuto(localPaths); } }
private void RemoveSelectedCallback(GitDiffWindow window) { string[] localPaths = window.GetStatusList().Where(window.IsSelected).SelectMany(e => gitManager.GetPathWithMeta(e.LocalPath)).ToArray(); if (gitManager.Threading.IsFlagSet(GitSettingsJson.ThreadingType.Unstage)) { gitManager.AsyncUnstage(localPaths).onComplete += (o) => { window.Repaint(); }; } else { GitCommands.Unstage(gitManager.Repository, localPaths); gitManager.MarkDirtyAuto(localPaths); } window.Repaint(); }
private void OnWizardCreate() { checkoutOptions.CheckoutModifiers = force ? CheckoutModifiers.Force : CheckoutModifiers.None; var branch = gitManager.Repository.Branches[branchNames[selectedBranch]]; if (branch != null) { GitCommands.Checkout(gitManager.Repository, branch, checkoutOptions); } else { logger.LogFormat(LogType.Error, "Could not find branch with name: {0}", branchNames[selectedBranch]); } }
public GitAsyncOperation AsyncUnstage(string[] paths) { var operation = asyncManager.QueueWorker(() => { GitCommands.Unstage(repository, paths); }, (o) => { MarkDirty(paths); asyncStages.RemoveAll(s => s.Equals(o)); callbacks.IssueAsyncStageOperationDone(o); }); asyncStages.Add(new AsyncStageOperation(operation, paths)); return(operation); }
private void OnWizardCreate() { try { MergeResult mergeResult = GitCommands.Pull(gitManager.Repository, gitManager.Signature, pullOptions); OnMergeComplete(mergeResult, "Pull"); } catch (Exception e) { logger.LogException(e); } finally { EditorUtility.ClearProgressBar(); } }
internal void Build(FileStatus fileStatus, GenericMenu menu, GitDiffWindow window) { menu.AddItem(new GUIContent("Select All"), false, () => SelectFilteredCallback(fileStatus, window)); if (GitManager.CanStage(fileStatus)) { menu.AddItem(new GUIContent("Add All"), false, () => { string[] paths = window.GetStatusList().Where(s => s.State.IsFlagSet(fileStatus)).SelectMany(s => gitManager.GetPathWithMeta(s.LocalPath)).ToArray(); if (gitManager.Threading.IsFlagSet(GitSettingsJson.ThreadingType.Stage)) { gitManager.AsyncStage(paths).onComplete += (o) => { window.Repaint(); }; } else { GitCommands.Stage(gitManager.Repository, paths); gitManager.MarkDirtyAuto(paths); } window.Repaint(); }); } else { menu.AddDisabledItem(new GUIContent("Add All")); } if (GitManager.CanUnstage(fileStatus)) { menu.AddItem(new GUIContent("Remove All"), false, () => { string[] paths = window.GetStatusList().Where(s => s.State.IsFlagSet(fileStatus)).SelectMany(s => gitManager.GetPathWithMeta(s.LocalPath)).ToArray(); if (gitManager.Threading.IsFlagSet(GitSettingsJson.ThreadingType.Unstage)) { gitManager.AsyncUnstage(paths).onComplete += (o) => { window.Repaint(); }; } else { GitCommands.Unstage(gitManager.Repository, paths); gitManager.MarkDirtyAuto(paths); } window.Repaint(); }); } else { menu.AddDisabledItem(new GUIContent("Remove All")); } }
public override void OnGUI(Rect rect) { GUILayout.Label(GitGUI.GetTempContent("Switch to: " + branch.FriendlyName), GitGUI.Styles.BigTitle, GUILayout.ExpandWidth(true)); force = EditorGUILayout.Toggle(GitGUI.GetTempContent("Force", "Override working tree changes"), force); if (GUILayout.Button(GitGUI.GetTempContent("Siwtch"))) { CheckoutOptions checkoutOptions = new CheckoutOptions() { OnCheckoutNotify = OnCheckoutNotify, OnCheckoutProgress = OnCheckoutProgress }; if (force) { checkoutOptions.CheckoutModifiers = CheckoutModifiers.Force; } if (branch != null) { try { GitCommands.Checkout(gitManager.Repository, branch, checkoutOptions); } catch (Exception e) { logger.LogFormat(LogType.Error, "There was a problem while switching to branch: {0}", branch.CanonicalName); logger.LogException(e); } finally { gitCallbacks.IssueAssetDatabaseRefresh(); gitManager.MarkDirty(true); } } else { logger.Log(LogType.Error, "Trying to switch to null branch"); } } }
private bool AutoFetchChanges() { if (gitManager.Repository == null || !initializer.IsValidRepo || !gitSettings.AutoFetch) { return(false); } Remote remote = gitManager.Repository.Network.Remotes.FirstOrDefault(); if (remote == null) { return(false); } GitProfilerProxy.BeginSample("Git automatic fetching"); try { GitCommands.Fetch(gitManager.Repository, remote, new FetchOptions() { CredentialsProvider = credentialsManager.FetchChangesAutoCredentialHandler, OnTransferProgress = gitManager.FetchTransferProgressHandler, RepositoryOperationStarting = (context) => { logger.Log(LogType.Log, "Repository Operation Starting"); return(true); } }); //Debug.LogFormat("Auto Fetch From remote: {0} - ({1}) successful.", remote.Name, remote.Url); } catch (Exception e) { logger.LogFormat(LogType.Error, "Automatic Fetching from remote: {0} with URL: {1} Failed!", remote.Name, remote.Url); logger.LogException(e); } finally { EditorUtility.ClearProgressBar(); GitProfilerProxy.EndSample(); } return(false); }
private void PostprocessUnstage(string[] paths) { if (repository == null || !IsValidRepo) { return; } if (prefs.GetBool(UnityEditorGitPrefs.DisablePostprocess)) { return; } string[] pathsFinal = paths.SelectMany(GetPathWithMeta).ToArray(); if (pathsFinal.Length > 0) { if (gitSettings != null && Threading.IsFlagSet(GitSettingsJson.ThreadingType.Unstage)) { AsyncUnstage(pathsFinal); } else { GitCommands.Unstage(repository, pathsFinal); MarkDirty(pathsFinal); } } }
private void OnWizardCreate() { try { GitCommands.Fetch(gitManager.Repository, remotes[selectedRemote], fetchOptions); #if UNITY_EDITOR logger.Log(LogType.Log, "Fetch Complete"); #endif var window = UniGitLoader.FindWindow <GitHistoryWindow>(); if (window != null) { window.ShowNotification(new GUIContent("Fetch Complete")); } gitManager.MarkDirty(true); } catch (Exception e) { logger.LogException(e); } finally { EditorUtility.ClearProgressBar(); } }