public bool TryAddSubmodule() { Verify.State.IsTrue(View != null, "Controller is not attached to a view."); var path = View.Path.Value.Trim(); if (!GitControllerUtility.ValidateRelativePath(path, View.Path, View.ErrorNotifier)) { return(false); } var url = View.Url.Value.Trim(); if (!GitControllerUtility.ValidateUrl(url, View.Url, View.ErrorNotifier)) { return(false); } string branch = null; if (View.UseCustomBranch.Value) { branch = View.BranchName.Value.Trim(); if (!GitControllerUtility.ValidateBranchName(branch, View.BranchName, View.ErrorNotifier)) { return(false); } } try { using (View.ChangeCursor(MouseCursor.WaitCursor)) { _repository.Submodules.Create(path, url, branch); } } catch (GitException exc) { GitterApplication.MessageBoxService.Show( View as IWin32Window, exc.Message, string.Format(Resources.ErrFailedToAddSubmodule, path), MessageBoxButton.Close, MessageBoxIcon.Error); return(false); } return(true); }
public bool TryClone() { Verify.State.IsTrue(View != null, "Controller is not attached to a view."); var url = View.Url.Value; if (!GitControllerUtility.ValidateUrl(url, View.Url, View.ErrorNotifier)) { return(false); } var path = View.RepositoryPath.Value.Trim(); if (!GitControllerUtility.ValidateAbsolutePath(path, View.RepositoryPath, View.ErrorNotifier)) { return(false); } var remoteName = View.RemoteName.Value; if (!GitControllerUtility.ValidateRemoteName(remoteName, View.RemoteName, View.ErrorNotifier)) { return(false); } url = url.Trim(); bool shallow = View.ShallowClone.Value; int depth = shallow ? View.Depth.Value : -1; string template = View.UseTemplate.Value ? View.TemplatePath.Value.Trim() : null; if (!string.IsNullOrWhiteSpace(template) && !GitControllerUtility.ValidateAbsolutePath(template, View.TemplatePath, View.ErrorNotifier)) { return(false); } bool bare = View.Bare.Value; bool mirror = bare && View.Mirror.Value; bool noCheckout = View.NoCheckout.Value; bool recursive = View.Recursive.Value; var status = GuiCommands.Clone(View as IWin32Window, GitRepositoryProvider.GitAccessor, url, path, template, remoteName, shallow, depth, bare, mirror, recursive, noCheckout); return(status == GuiCommandStatus.Completed); }
public bool TryAddRemote() { Verify.State.IsTrue(View != null, "Controller is not attached to a view."); var name = View.RemoteName.Value; if (!GitControllerUtility.ValidateNewRemoteName(name, Repository, View.RemoteName, View.ErrorNotifier)) { return(false); } var url = View.Url.Value; if (!GitControllerUtility.ValidateUrl(url, View.Url, View.ErrorNotifier)) { return(false); } name = name.Trim(); url = url.Trim(); var fetch = View.Fetch.Value; var mirror = View.Mirror.Value; var tagFetchMode = View.TagFetchMode.Value; try { using (View.ChangeCursor(MouseCursor.WaitCursor)) { Repository.Remotes.AddRemote(name, url, fetch, mirror, tagFetchMode); } } catch (GitException exc) { GitterApplication.MessageBoxService.Show( View as IWin32Window, exc.Message, Resources.ErrFailedToAddRemote, MessageBoxButton.Close, MessageBoxIcon.Error); return(false); } return(true); }