private void OnTreeNodeGUI(BranchTreeNode node) { // Content, style, and rects Texture2D iconContent; if (node.Active == true) { iconContent = Styles.ActiveBranchIcon; } else { if (node.Children.Count > 0) { iconContent = Styles.FolderIcon; } else { iconContent = Styles.BranchIcon; } } var content = new GUIContent(node.Label, iconContent); var style = node.Active ? Styles.BoldLabel : Styles.Label; var rect = GUILayoutUtility.GetRect(content, style, GUILayout.MaxHeight(EditorGUIUtility.singleLineHeight)); var clickRect = new Rect(0f, rect.y, Position.width, rect.height); var favouriteRect = new Rect(clickRect.xMax - clickRect.height * 2f, clickRect.y, clickRect.height, clickRect.height); var selected = selectedNode == node; var keyboardFocus = GUIUtility.keyboardControl == listID; // Selection highlight and favourite toggle if (selected) { if (Event.current.type == EventType.Repaint) { style.Draw(clickRect, GUIContent.none, false, false, true, keyboardFocus); } if (node.Type != NodeType.Folder) { var favourite = GetFavourite(node); if (Event.current.type == EventType.Repaint) { GUI.DrawTexture(favouriteRect, favourite ? Styles.FavouriteIconOn : Styles.FavouriteIconOff); } else if (Event.current.type == EventType.MouseDown && favouriteRect.Contains(Event.current.mousePosition)) { SetFavourite(node, !favourite); Event.current.Use(); } } } // Favourite status else if (Event.current.type == EventType.Repaint && node.Type != NodeType.Folder && GetFavourite(node.Name)) { GUI.DrawTexture(favouriteRect, Styles.FavouriteIconOn); } // The actual icon and label if (Event.current.type == EventType.Repaint) { style.Draw(rect, content, false, false, selected, keyboardFocus); } // Children GUILayout.BeginHorizontal(); { GUILayout.Space(Styles.TreeIndentation); GUILayout.BeginVertical(); { OnTreeNodeChildrenGUI(node); } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); // Click selection of the node as well as branch switch if (Event.current.type == EventType.MouseDown && clickRect.Contains(Event.current.mousePosition)) { newNodeSelection = node; Event.current.Use(); if (Event.current.clickCount > 1 && mode == BranchesMode.Default) { if (node.Type == NodeType.LocalBranch && EditorUtility.DisplayDialog(ConfirmSwitchTitle, String.Format(ConfirmSwitchMessage, node.Name), ConfirmSwitchOK, ConfirmSwitchCancel)) { GitClient.SwitchBranch(node.Name) .FinallyInUI((success, e) => { if (success) { Refresh(); } else { EditorUtility.DisplayDialog(Localization.SwitchBranchTitle, String.Format(Localization.SwitchBranchFailedDescription, node.Name), Localization.Ok); } }).Start(); } else if (node.Type == NodeType.RemoteBranch) { GitClient.CreateBranch(selectedNode.Name.Substring(selectedNode.Name.IndexOf('/') + 1), selectedNode.Name) .FinallyInUI((success, e) => { if (success) { Refresh(); } else { EditorUtility.DisplayDialog(Localization.SwitchBranchTitle, String.Format(Localization.SwitchBranchFailedDescription, node.Name), Localization.Ok); } }).Start(); } } } }
public void SetupGit(GitInstaller.GitInstallationState state) { if (!state.GitIsValid || !state.GitLfsIsValid) { if (!state.GitExecutablePath.IsInitialized) { Logger.Warning(Localization.GitNotFound); } else if (!state.GitLfsExecutablePath.IsInitialized) { Logger.Warning(Localization.GitLFSNotFound); } else if (state.GitVersion < Constants.MinimumGitVersion) { Logger.Warning(String.Format(Localization.GitVersionTooLow, state.GitExecutablePath, state.GitVersion, Constants.MinimumGitVersion)); } else if (state.GitLfsVersion < Constants.MinimumGitLfsVersion) { Logger.Warning(String.Format(Localization.GitLfsVersionTooLow, state.GitLfsExecutablePath, state.GitLfsVersion, Constants.MinimumGitLfsVersion)); } return; } Environment.GitInstallationState = state; Environment.User.Initialize(GitClient); if (firstRun) { if (Environment.RepositoryPath.IsInitialized) { UpdateMergeSettings(); GitClient.LfsInstall() .Catch(e => { Logger.Error(e, "Error running lfs install"); return(true); }) .RunSynchronously(); } if (Environment.IsWindows) { var credentialHelper = GitClient.GetConfig("credential.helper", GitConfigSource.Global) .Catch(e => { Logger.Error(e, "Error getting the credential helper"); return(true); }).RunSynchronously(); if (string.IsNullOrEmpty(credentialHelper)) { Logger.Warning("No Windows CredentialHelper found: Setting to wincred"); GitClient.SetConfig("credential.helper", "wincred", GitConfigSource.Global) .Catch(e => { Logger.Error(e, "Error setting the credential helper"); return(true); }) .RunSynchronously(); } } } }
public override void OnGUI() { GUILayout.BeginHorizontal(Styles.AuthHeaderBoxStyle); { GUILayout.BeginVertical(GUILayout.Width(16)); { GUILayout.Space(9); GUILayout.Label(Styles.BigLogo, GUILayout.Height(20), GUILayout.Width(20)); } GUILayout.EndVertical(); GUILayout.BeginVertical(); { GUILayout.Space(11); GUILayout.Label(Title, EditorStyles.boldLabel); } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); GUILayout.Space(Styles.PublishViewSpacingHeight); GUILayout.BeginHorizontal(); { GUILayout.BeginVertical(); { GUILayout.Label("Owner"); GUI.enabled = !isBusy; selectedOwner = EditorGUILayout.Popup(0, owners); GUI.enabled = true; } GUILayout.EndVertical(); GUILayout.BeginVertical(GUILayout.Width(8)); { GUILayout.Space(20); GUILayout.Label("/"); } GUILayout.EndVertical(); GUILayout.BeginVertical(); { GUILayout.Label("Repository Name"); GUI.enabled = !isBusy; repoName = EditorGUILayout.TextField(repoName); GUI.enabled = true; } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); GUILayout.Label("Description"); GUI.enabled = !isBusy; repoDescription = EditorGUILayout.TextField(repoDescription); GUI.enabled = true; GUILayout.Space(Styles.PublishViewSpacingHeight); GUILayout.BeginVertical(); { GUILayout.BeginHorizontal(); { GUI.enabled = !isBusy; togglePrivate = GUILayout.Toggle(togglePrivate, "Create as a private repository"); GUI.enabled = true; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Space(Styles.PublishViewSpacingHeight); var repoPrivacyExplanation = togglePrivate ? PrivateRepoMessage : PublicRepoMessage; GUILayout.Label(repoPrivacyExplanation, Styles.LongMessageStyle); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); GUILayout.Space(Styles.PublishViewSpacingHeight); if (error != null) { GUILayout.Label(error, Styles.ErrorLabel); } GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); GUI.enabled = !string.IsNullOrEmpty(repoName) && !isBusy; if (GUILayout.Button(PublishViewCreateButton)) { isBusy = true; var organization = owners[selectedOwner] == username ? null : owners[selectedOwner]; Client.CreateRepository(new NewRepository(repoName) { Private = togglePrivate, }, (repository, ex) => { Logger.Trace("Create Repository Callback"); if (ex != null) { error = ex.Message; isBusy = false; return; } if (repository == null) { Logger.Warning("Returned Repository is null"); isBusy = false; return; } var repositoryCloneUrl = Environment.IsWindows ? repository.CloneUrl : repository.SshUrl; GitClient.RemoteAdd("origin", repositoryCloneUrl) .Then(GitClient.Push("origin", Repository.CurrentBranch.Value.Name)) .ThenInUI(Parent.Finish) .Start(); }, organization); } GUI.enabled = true; } GUILayout.EndHorizontal(); GUILayout.Space(10); }
private void OnCreateGUI() { // Create button if (mode == BranchesMode.Default) { // If the current branch is selected, then do not enable the Delete button var disableDelete = activeBranchNode == selectedNode; EditorGUI.BeginDisabledGroup(disableDelete); { if (GUILayout.Button("Delete", EditorStyles.miniButton, GUILayout.ExpandWidth(false))) { var selectedBranchName = selectedNode.Name; var dialogTitle = "Delete Branch: " + selectedBranchName; var dialogMessage = "Are you sure you want to delete the branch: " + selectedBranchName + "?"; if (EditorUtility.DisplayDialog("Delete Branch?", dialogMessage, "Delete", "Cancel")) { GitClient.DeleteBranch(selectedBranchName, true).Start(); } } } EditorGUI.EndDisabledGroup(); GUILayout.FlexibleSpace(); if (GUILayout.Button(CreateBranchButton, EditorStyles.miniButton, GUILayout.ExpandWidth(false))) { targetMode = BranchesMode.Create; } } // Branch name + cancel + create else if (mode == BranchesMode.Create) { GUILayout.BeginHorizontal(); { var createBranch = false; var cancelCreate = false; var cannotCreate = selectedNode == null || selectedNode.Type == NodeType.Folder || !Validation.IsBranchNameValid(newBranchName); // Create on return/enter or cancel on escape var offsetID = GUIUtility.GetControlID(FocusType.Passive); if (Event.current.isKey && GUIUtility.keyboardControl == offsetID + 1) { if (Event.current.keyCode == KeyCode.Escape) { cancelCreate = true; Event.current.Use(); } else if (Event.current.keyCode == KeyCode.Return || Event.current.keyCode == KeyCode.KeypadEnter) { if (cannotCreate) { EditorApplication.Beep(); } else { createBranch = true; } Event.current.Use(); } } newBranchName = EditorGUILayout.TextField(newBranchName); // Create EditorGUI.BeginDisabledGroup(cannotCreate); { if (GUILayout.Button(NewBranchConfirmButton, EditorStyles.miniButtonLeft, GUILayout.ExpandWidth(false))) { createBranch = true; } } EditorGUI.EndDisabledGroup(); // Cancel create if (GUILayout.Button(NewBranchCancelButton, EditorStyles.miniButtonRight, GUILayout.ExpandWidth(false))) { cancelCreate = true; } // Effectuate create if (createBranch) { GitClient.CreateBranch(newBranchName, selectedNode.Name) .FinallyInUI((success, e) => { if (success) { Refresh(); } else { var errorHeader = "fatal: "; var errorMessage = e.Message.StartsWith(errorHeader) ? e.Message.Remove(0, errorHeader.Length) : e.Message; EditorUtility.DisplayDialog(CreateBranchTitle, errorMessage, Localization.Ok); } }) .Start(); } // Cleanup if (createBranch || cancelCreate) { newBranchName = ""; GUIUtility.keyboardControl = -1; targetMode = BranchesMode.Default; } } GUILayout.EndHorizontal(); } }
public ITask CreateBranch(string branch, string baseBranch) { var task = GitClient.CreateBranch(branch, baseBranch); return(HookupHandlers(task)); }
public ITask Pull(string remote, string branch) { var task = GitClient.Pull(remote, branch); return(HookupHandlers(task, true)); }
public ITask UnlockFile(string file, bool force) { var task = GitClient.Unlock(file, force); return(HookupHandlers(task, false).Then(UpdateLocks)); }
public ITask SwitchBranch(string branch) { var task = GitClient.SwitchBranch(branch); return(HookupHandlers(task, true)); }
public ITask RemoteRemove(string remote) { var task = GitClient.RemoteRemove(remote); return(HookupHandlers(task, true)); }
public ITask LockFile(string file) { var task = GitClient.Lock(file); return(HookupHandlers(task, false).Then(UpdateLocks)); }
public ITask RemoteAdd(string remote, string url) { var task = GitClient.RemoteAdd(remote, url); return(HookupHandlers(task, true)); }
private void OnButtonBarGUI() { if (mode == BranchesMode.Default) { // Delete button // If the current branch is selected, then do not enable the Delete button EditorGUI.BeginDisabledGroup(disableDelete); { if (GUILayout.Button(DeleteBranchButton, EditorStyles.miniButton, GUILayout.ExpandWidth(false))) { DeleteLocalBranch(treeLocals.SelectedNode.Path); } } EditorGUI.EndDisabledGroup(); // Create button GUILayout.FlexibleSpace(); EditorGUI.BeginDisabledGroup(disableCreate); { if (GUILayout.Button(CreateBranchButton, EditorStyles.miniButton, GUILayout.ExpandWidth(false))) { targetMode = BranchesMode.Create; } } EditorGUI.EndDisabledGroup(); } // Branch name + cancel + create else if (mode == BranchesMode.Create) { GUILayout.BeginHorizontal(); { var createBranch = false; var cancelCreate = false; var cannotCreate = treeLocals.SelectedNode == null || treeLocals.SelectedNode.IsFolder || !Validation.IsBranchNameValid(newBranchName); // Create on return/enter or cancel on escape var offsetID = GUIUtility.GetControlID(FocusType.Passive); if (Event.current.isKey && GUIUtility.keyboardControl == offsetID + 1) { if (Event.current.keyCode == KeyCode.Escape) { cancelCreate = true; Event.current.Use(); } else if (Event.current.keyCode == KeyCode.Return || Event.current.keyCode == KeyCode.KeypadEnter) { if (cannotCreate) { EditorApplication.Beep(); } else { createBranch = true; } Event.current.Use(); } } newBranchName = EditorGUILayout.TextField(newBranchName); // Create EditorGUI.BeginDisabledGroup(cannotCreate); { if (GUILayout.Button(NewBranchConfirmButton, EditorStyles.miniButtonLeft, GUILayout.ExpandWidth(false))) { createBranch = true; } } EditorGUI.EndDisabledGroup(); // Cancel create if (GUILayout.Button(NewBranchCancelButton, EditorStyles.miniButtonRight, GUILayout.ExpandWidth(false))) { cancelCreate = true; } // Effectuate create if (createBranch) { GitClient.CreateBranch(newBranchName, treeLocals.SelectedNode.Path) .FinallyInUI((success, e) => { if (success) { TaskManager.Run(UsageTracker.IncrementNumberOfLocalBranchCreations); Redraw(); } else { var errorHeader = "fatal: "; var errorMessage = e.Message.StartsWith(errorHeader) ? e.Message.Remove(0, errorHeader.Length) : e.Message; EditorUtility.DisplayDialog(CreateBranchTitle, errorMessage, Localization.Ok); } }) .Start(); } // Cleanup if (createBranch || cancelCreate) { newBranchName = ""; GUIUtility.keyboardControl = -1; targetMode = BranchesMode.Default; } } GUILayout.EndHorizontal(); } }
private void ValidateAndSetGitInstallPath(string value) { value = value.Trim(); if (value == portableGitPath) { Logger.Trace("Attempting to restore portable Git Path:{0}", value); var gitInstaller = new GitInstaller(Environment, EntryPoint.ApplicationManager.ProcessManager, EntryPoint.ApplicationManager.TaskManager); gitInstaller.SetupGitIfNeeded() .FinallyInUI((success, exception, installationState) => { Logger.Trace("Setup Git Using the installer:{0}", success); if (!success) { Logger.Error(exception, ErrorInstallingInternalGit); gitVersionErrorMessage = ErrorValidatingGitPath; } else { Manager.SystemSettings.Unset(Constants.GitInstallPathKey); Environment.GitExecutablePath = installationState.GitExecutablePath; Environment.GitLfsExecutablePath = installationState.GitLfsExecutablePath; Environment.IsCustomGitExecutable = false; gitExecHasChanged = true; } isBusy = false; }).Start(); } else { //Logger.Trace("Validating Git Path:{0}", value); gitVersionErrorMessage = null; GitClient.ValidateGitInstall(value.ToNPath(), true) .ThenInUI((success, result) => { if (!success) { Logger.Trace(ErrorValidatingGitPath); gitVersionErrorMessage = ErrorValidatingGitPath; } else if (!result.IsValid) { Logger.Warning( "Software versions do not meet minimums Git:{0} (Minimum:{1}) GitLfs:{2} (Minimum:{3})", result.GitVersion, Constants.MinimumGitVersion, result.GitLfsVersion, Constants.MinimumGitLfsVersion); var errorMessageStringBuilder = new StringBuilder(); if (result.GitVersion == null) { errorMessageStringBuilder.Append(ErrorGitNotFoundMessage); } else if (result.GitLfsVersion == null) { errorMessageStringBuilder.Append(ErrorGitLfsNotFoundMessage); } else { if (result.GitVersion < Constants.MinimumGitVersion) { errorMessageStringBuilder.AppendFormat(ErrorMinimumGitVersionMessageFormat, result.GitVersion, Constants.MinimumGitVersion); } if (result.GitLfsVersion < Constants.MinimumGitLfsVersion) { if (errorMessageStringBuilder.Length > 0) { errorMessageStringBuilder.Append(Environment.NewLine); } errorMessageStringBuilder.AppendFormat(ErrorMinimumGitLfsVersionMessageFormat, result.GitLfsVersion, Constants.MinimumGitLfsVersion); } } gitVersionErrorMessage = errorMessageStringBuilder.ToString(); } else { Logger.Trace("Software versions meet minimums Git:{0} GitLfs:{1}", result.GitVersion, result.GitLfsVersion); Manager.SystemSettings.Set(Constants.GitInstallPathKey, value); Environment.GitExecutablePath = value.ToNPath(); Environment.IsCustomGitExecutable = true; gitExecHasChanged = true; } isBusy = false; }).Start(); } }
public ITask Fetch(string remote) { var task = GitClient.Fetch(remote); return(HookupHandlers(task)); }
public override void OnGUI() { GUILayout.BeginHorizontal(Styles.AuthHeaderBoxStyle); { GUILayout.Label(PublishToGithubLabel, EditorStyles.boldLabel); } GUILayout.EndHorizontal(); EditorGUI.BeginDisabledGroup(isBusy); { selectedOwner = EditorGUILayout.Popup(SelectedOwnerLabel, selectedOwner, owners); repoName = EditorGUILayout.TextField(RepositoryNameLabel, repoName); repoDescription = EditorGUILayout.TextField(DescriptionLabel, repoDescription); togglePrivate = EditorGUILayout.Toggle(CreatePrivateRepositoryLabel, togglePrivate); var repoPrivacyExplanation = togglePrivate ? PrivateRepoMessage : PublicRepoMessage; EditorGUILayout.HelpBox(repoPrivacyExplanation, MessageType.None); GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); EditorGUI.BeginDisabledGroup(!IsFormValid); if (GUILayout.Button(PublishViewCreateButton)) { GUI.FocusControl(null); isBusy = true; var organization = owners[selectedOwner] == username ? null : owners[selectedOwner]; var cleanRepoDescription = repoDescription.Trim(); cleanRepoDescription = string.IsNullOrEmpty(cleanRepoDescription) ? null : cleanRepoDescription; Client.CreateRepository(repoName, cleanRepoDescription, togglePrivate, (repository, ex) => { if (ex != null) { Logger.Error(ex, "Repository Create Error Type:{0}", ex.GetType().ToString()); error = GetPublishErrorMessage(ex); isBusy = false; return; } if (repository == null) { Logger.Warning("Returned Repository is null"); isBusy = false; return; } Logger.Trace("Repository Created"); GitClient.RemoteAdd("origin", repository.CloneUrl) .Then(GitClient.Push("origin", Repository.CurrentBranch.Value.Name)) .ThenInUI(Finish) .Start(); }, organization); } EditorGUI.EndDisabledGroup(); } GUILayout.EndHorizontal(); GUILayout.Space(10); if (error != null) { EditorGUILayout.HelpBox(error, MessageType.Error); } GUILayout.FlexibleSpace(); } EditorGUI.EndDisabledGroup(); }
public ITask RemoteChange(string remote, string url) { var task = GitClient.RemoteChange(remote, url); return(HookupHandlers(task)); }
private void OnTreeNodeGUI(BranchTreeNode node) { // Content, style, and rects Texture2D iconContent; if (node.Active == true) { iconContent = Styles.ActiveBranchIcon; } else { if (node.Children.Count > 0) { iconContent = Styles.FolderIcon; } else { iconContent = Styles.BranchIcon; } } var content = new GUIContent(node.Label, iconContent); var style = node.Active ? Styles.BoldLabel : Styles.Label; var rect = GUILayoutUtility.GetRect(content, style, GUILayout.MaxHeight(EditorGUIUtility.singleLineHeight)); var clickRect = new Rect(0f, rect.y, Position.width, rect.height); var selected = selectedNode == node; var keyboardFocus = GUIUtility.keyboardControl == listID; // Selection highlight and favorite toggle if (selected) { if (Event.current.type == EventType.Repaint) { style.Draw(clickRect, GUIContent.none, false, false, true, keyboardFocus); } } // The actual icon and label if (Event.current.type == EventType.Repaint) { style.Draw(rect, content, false, false, selected, keyboardFocus); } // Children GUILayout.BeginHorizontal(); { GUILayout.Space(Styles.TreeIndentation); GUILayout.BeginVertical(); { OnTreeNodeChildrenGUI(node); } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); // Click selection of the node as well as branch switch if (Event.current.type == EventType.MouseDown && clickRect.Contains(Event.current.mousePosition)) { newNodeSelection = node; Event.current.Use(); if (Event.current.clickCount > 1 && mode == BranchesMode.Default) { if (node.Type == NodeType.LocalBranch) { if (EditorUtility.DisplayDialog(ConfirmSwitchTitle, String.Format(ConfirmSwitchMessage, node.Name), ConfirmSwitchOK, ConfirmSwitchCancel)) { GitClient.SwitchBranch(node.Name) .FinallyInUI((success, e) => { if (success) { Redraw(); } else { EditorUtility.DisplayDialog(Localization.SwitchBranchTitle, String.Format(Localization.SwitchBranchFailedDescription, node.Name), Localization.Ok); } }).Start(); } } else if (node.Type == NodeType.RemoteBranch) { var indexOfFirstSlash = selectedNode.Name.IndexOf('/'); var originName = selectedNode.Name.Substring(0, indexOfFirstSlash); var branchName = selectedNode.Name.Substring(indexOfFirstSlash + 1); if (localBranches.Any(localBranch => localBranch.Name == branchName)) { EditorUtility.DisplayDialog(WarningCheckoutBranchExistsTitle, String.Format(WarningCheckoutBranchExistsMessage, branchName), WarningCheckoutBranchExistsOK); } else { var confirmCheckout = EditorUtility.DisplayDialog(ConfirmCheckoutBranchTitle, String.Format(ConfirmCheckoutBranchMessage, node.Name, originName), ConfirmCheckoutBranchOK, ConfirmCheckoutBranchCancel); if (confirmCheckout) { GitClient.CreateBranch(branchName, selectedNode.Name) .FinallyInUI((success, e) => { if (success) { Redraw(); } else { EditorUtility.DisplayDialog(Localization.SwitchBranchTitle, String.Format(Localization.SwitchBranchFailedDescription, node.Name), Localization.Ok); } }).Start(); } } } } } }
public ITask DeleteBranch(string branch, bool deleteUnmerged = false) { var task = GitClient.DeleteBranch(branch, deleteUnmerged); return(HookupHandlers(task)); }
private void MaybeUpdateData() { if (lockedFiles == null) { lockedFiles = new List <GitLock>(); } if (Repository == null) { if ((cachedUser == null || String.IsNullOrEmpty(cachedUser.Name)) && GitClient != null) { var user = new User(); GitClient.GetConfig("user.name", GitConfigSource.User) .Then((success, value) => user.Name = value).Then( GitClient.GetConfig("user.email", GitConfigSource.User) .Then((success, value) => user.Email = value)) .FinallyInUI((success, ex) => { if (success && !String.IsNullOrEmpty(user.Name)) { cachedUser = user; userDataHasChanged = true; Redraw(); } }) .Start(); } if (userDataHasChanged) { newGitName = gitName = cachedUser.Name; newGitEmail = gitEmail = cachedUser.Email; userDataHasChanged = false; } return; } userDataHasChanged = Repository.User.Name != gitName || Repository.User.Email != gitEmail; if (!remoteHasChanged && !userDataHasChanged) { return; } if (userDataHasChanged) { userDataHasChanged = false; newGitName = gitName = Repository.User.Name; newGitEmail = gitEmail = Repository.User.Email; } if (remoteHasChanged) { remoteHasChanged = false; var activeRemote = Repository.CurrentRemote; hasRemote = activeRemote.HasValue && !String.IsNullOrEmpty(activeRemote.Value.Url); if (!hasRemote) { repositoryRemoteName = DefaultRepositoryRemoteName; newRepositoryRemoteUrl = repositoryRemoteUrl = string.Empty; } else { repositoryRemoteName = activeRemote.Value.Name; newRepositoryRemoteUrl = repositoryRemoteUrl = activeRemote.Value.Url; } } }
public override void OnGUI() { GUILayout.Label(GitConfigTitle, EditorStyles.boldLabel); EditorGUI.BeginDisabledGroup(IsBusy || Parent.IsBusy); { newGitName = EditorGUILayout.TextField(GitConfigNameLabel, newGitName); newGitEmail = EditorGUILayout.TextField(GitConfigEmailLabel, newGitEmail); var needsSaving = (newGitName != gitName || newGitEmail != gitEmail) && !(string.IsNullOrEmpty(newGitName) || string.IsNullOrEmpty(newGitEmail)); EditorGUI.BeginDisabledGroup(!needsSaving); { if (GUILayout.Button(GitConfigUserSave, GUILayout.ExpandWidth(false))) { GUI.FocusControl(null); isBusy = true; GitClient.SetConfig("user.name", newGitName, GitConfigSource.User) .Then((success, value) => { if (success) { if (Repository != null) { Repository.User.Name = newGitName; } else { if (cachedUser == null) { cachedUser = new User(); } cachedUser.Name = newGitName; } } }) .Then( GitClient.SetConfig("user.email", newGitEmail, GitConfigSource.User) .Then((success, value) => { if (success) { if (Repository != null) { Repository.User.Email = newGitEmail; } else { cachedUser.Email = newGitEmail; } userDataHasChanged = true; } })) .FinallyInUI((_, __) => { isBusy = false; Redraw(); }) .Start(); } } EditorGUI.EndDisabledGroup(); } EditorGUI.EndDisabledGroup(); }
private void OnUserSettingsGUI() { GUILayout.Label(GitConfigTitle, EditorStyles.boldLabel); EditorGUI.BeginDisabledGroup(isBusy); { newGitName = EditorGUILayout.TextField(GitConfigNameLabel, newGitName); newGitEmail = EditorGUILayout.TextField(GitConfigEmailLabel, newGitEmail); var needsSaving = newGitName != gitName || newGitEmail != gitEmail; EditorGUI.BeginDisabledGroup(!needsSaving); { if (GUILayout.Button(GitConfigUserSave, GUILayout.ExpandWidth(false))) { GitClient.SetConfig("user.name", newGitName, GitConfigSource.User) .Then((success, value) => { if (success) { if (Repository != null) { Repository.User.Name = value; } else { if (cachedUser == null) { cachedUser = new User(); } cachedUser.Name = value; } } }) .Then( GitClient.SetConfig("user.email", newGitEmail, GitConfigSource.User) .Then((success, value) => { if (success) { if (Repository != null) { Repository.User.Email = value; } else { cachedUser.Email = value; userDataHasChanged = true; } } })) .FinallyInUI((_, __) => { isBusy = false; Redraw(); }) .Start(); isBusy = true; } } EditorGUI.EndDisabledGroup(); } EditorGUI.EndDisabledGroup(); }
public ITask Revert(string changeset) { var task = GitClient.Revert(changeset); return(HookupHandlers(task, true)); }
public override void OnGUI() { GUILayout.BeginHorizontal(Styles.AuthHeaderBoxStyle); { GUILayout.BeginVertical(GUILayout.Width(16)); { GUILayout.Space(9); GUILayout.Label(Styles.BigLogo, GUILayout.Height(20), GUILayout.Width(20)); } GUILayout.EndVertical(); GUILayout.BeginVertical(); { GUILayout.Space(11); GUILayout.Label(Title, EditorStyles.boldLabel); } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); GUILayout.Space(Styles.PublishViewSpacingHeight); EditorGUI.BeginDisabledGroup(isBusy); { GUILayout.BeginHorizontal(); { GUILayout.BeginVertical(); { GUILayout.Label(SelectedOwnerLabel); selectedOwner = EditorGUILayout.Popup(selectedOwner, owners); } GUILayout.EndVertical(); GUILayout.BeginVertical(GUILayout.Width(8)); { GUILayout.Space(20); GUILayout.Label("/"); } GUILayout.EndVertical(); GUILayout.BeginVertical(); { GUILayout.Label(RepositoryNameLabel); repoName = EditorGUILayout.TextField(repoName); } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); GUILayout.Label(DescriptionLabel); repoDescription = EditorGUILayout.TextField(repoDescription); GUILayout.Space(Styles.PublishViewSpacingHeight); GUILayout.BeginVertical(); { GUILayout.BeginHorizontal(); { togglePrivate = GUILayout.Toggle(togglePrivate, CreatePrivateRepositoryLabel); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Space(Styles.PublishViewSpacingHeight); var repoPrivacyExplanation = togglePrivate ? PrivateRepoMessage : PublicRepoMessage; GUILayout.Label(repoPrivacyExplanation, Styles.LongMessageStyle); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); GUILayout.Space(Styles.PublishViewSpacingHeight); if (error != null) { GUILayout.Label(error, Styles.ErrorLabel); } GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); EditorGUI.BeginDisabledGroup(!IsFormValid); if (GUILayout.Button(PublishViewCreateButton)) { isBusy = true; var organization = owners[selectedOwner] == username ? null : owners[selectedOwner]; Client.CreateRepository(new NewRepository(repoName) { Private = togglePrivate, }, (repository, ex) => { Logger.Trace("Create Repository Callback"); if (ex != null) { error = ex.Message; isBusy = false; return; } if (repository == null) { Logger.Warning("Returned Repository is null"); isBusy = false; return; } GitClient.RemoteAdd("origin", repository.CloneUrl) .Then(GitClient.Push("origin", Repository.CurrentBranch.Value.Name)) .ThenInUI(Finish) .Start(); }, organization); } EditorGUI.EndDisabledGroup(); } GUILayout.EndHorizontal(); GUILayout.Space(10); } EditorGUI.EndDisabledGroup(); }