public int Run(string tfsUrl, string tfsRepositoryPath, string gitRepositoryPath) { var currentDir = Environment.CurrentDirectory; var repositoryDirCreated = InitGitDir(gitRepositoryPath); // TFS string representations of repository paths do not end in trailing slashes tfsRepositoryPath = (tfsRepositoryPath ?? string.Empty).TrimEnd('/'); try { var retVal = init.Run(tfsUrl, tfsRepositoryPath, gitRepositoryPath); VerifyTfsPathToClone(tfsRepositoryPath); if (retVal == 0) { retVal = fetch.Run(); } if (retVal == 0) { globals.Repository.CommandNoisy("merge", globals.Repository.ReadTfsRemote(globals.RemoteId).RemoteRef); } if (retVal == 0 && withBranches && initBranch != null) { initBranch.CloneAllBranches = true; retVal = initBranch.Run(); } return(retVal); } catch { try { // if we appeared to be inside repository dir when exception was thrown - we won't be able to delete it Environment.CurrentDirectory = currentDir; if (repositoryDirCreated) { Directory.Delete(gitRepositoryPath, recursive: true); } else { CleanDirectory(gitRepositoryPath); } } catch (IOException e) { // swallow IOException. Smth went wrong before this and we're much more interested in that error string msg = String.Format("Something went wrong, can't cleanup files because of IOException:\n{0}\n", e.IndentExceptionMessage()); Trace.WriteLine(msg); } catch (UnauthorizedAccessException e) { // swallow it also string msg = String.Format("Something went wrong, can't cleanup files because of UnauthorizedAccessException:\n{0}\n", e.IndentExceptionMessage()); Trace.WriteLine(msg); } throw; } }
public int Run(string remoteId) { var retVal = fetch.Run(remoteId); if (retVal == 0) { var remote = globals.Repository.ReadTfsRemote(remoteId); if (_shouldRebase) { globals.WarnOnGitVersion(stdout); if (globals.Repository.WorkingCopyHasUnstagedOrUncommitedChanges) { throw new GitTfsException("error: You have local changes; rebase-workflow only possible with clean working directory.") .WithRecommendation("Try 'git stash' to stash your local changes and pull again."); } globals.Repository.CommandNoisy("rebase", "--preserve-merges", remote.RemoteRef); } else { globals.Repository.CommandNoisy("merge", remote.RemoteRef); } } return(retVal); }
public int Run(IList <string> args) { var retVal = 0; retVal = fetch.Run(); if (retVal == 0) { globals.Repository.CommandNoisy("merge", "tfs/default"); } return(retVal); }
public int Run(string remoteId) { var retVal = fetch.Run(remoteId); if (retVal == 0) { var remote = globals.Repository.ReadTfsRemote(remoteId); globals.Repository.CommandNoisy("merge", remote.RemoteRef); } return(retVal); }
public int Run(string tfsUrl, string tfsRepositoryPath, string gitRepositoryPath) { var currentDir = Environment.CurrentDirectory; var repositoryDirCreated = InitGitDir(gitRepositoryPath); try { var retVal = 0; retVal = init.Run(tfsUrl, tfsRepositoryPath, gitRepositoryPath); if (retVal == 0) { retVal = fetch.Run(); } if (retVal == 0) { globals.Repository.CommandNoisy("merge", globals.Repository.ReadAllTfsRemotes().First().RemoteRef); } return(retVal); } catch { try { // if we appeared to be inside repository dir when exception was thrown - we won't be able to delete it Environment.CurrentDirectory = currentDir; if (repositoryDirCreated) { Directory.Delete(gitRepositoryPath, recursive: true); } else { CleanDirectory(gitRepositoryPath); } } catch (IOException e) { // swallow IOException. Smth went wrong before this and we're much more interested in that error string msg = String.Format("Something went wrong, can't cleanup files because of IOException:\n{0}\n", e.IndentExceptionMessage()); Trace.WriteLine(msg); } catch (UnauthorizedAccessException e) { // swallow it also string msg = String.Format("Something went wrong, can't cleanup files because of UnauthorizedAccessException:\n{0}\n", e.IndentExceptionMessage()); Trace.WriteLine(msg); } throw; } }
public int Run(string tfsUrl, string tfsRepositoryPath, string gitRepositoryPath) { var retVal = 0; retVal = init.Run(tfsUrl, tfsRepositoryPath, gitRepositoryPath); if (retVal == 0) { retVal = fetch.Run(); } if (retVal == 0) { globals.Repository.CommandNoisy("merge", globals.Repository.ReadAllTfsRemotes().First().RemoteRef); } return(retVal); }
public int DoPull(string remoteId) { ValidatePrefix(); remoteId = remoteId ?? string.Format(GitTfsConstants.RemoteSubtreeFormat, _globals.RemoteId ?? GitTfsConstants.DefaultRepositoryId, Prefix); IGitTfsRemote remote = _globals.Repository.ReadTfsRemote(remoteId); int result = _fetch.Run(remote.Id); if (result == GitTfsExitCodes.OK) { var p = Prefix.Replace(" ", "\\ "); _globals.Repository.CommandNoisy("subtree", "merge", "--prefix=" + p, remote.RemoteRef); result = GitTfsExitCodes.OK; } return(result); }
public int Run(string tfsUrl, string tfsRepositoryPath, string gitRepositoryPath) { var currentDir = Environment.CurrentDirectory; var repositoryDirCreated = InitGitDir(gitRepositoryPath); // TFS string representations of repository paths do not end in trailing slashes if (tfsRepositoryPath != GitTfsConstants.TfsRoot) { tfsRepositoryPath = (tfsRepositoryPath ?? string.Empty).TrimEnd('/'); } int retVal = 0; try { if (repositoryDirCreated) { retVal = init.Run(tfsUrl, tfsRepositoryPath, gitRepositoryPath); } else { try { Environment.CurrentDirectory = gitRepositoryPath; globals.Repository = init.GitHelper.MakeRepository(globals.GitDir); } catch (Exception) { retVal = init.Run(tfsUrl, tfsRepositoryPath, gitRepositoryPath); } } VerifyTfsPathToClone(tfsRepositoryPath); } catch { if (!resumable) { try { // if we appeared to be inside repository dir when exception was thrown - we won't be able to delete it Environment.CurrentDirectory = currentDir; if (repositoryDirCreated) { Directory.Delete(gitRepositoryPath, recursive: true); } else { CleanDirectory(gitRepositoryPath); } } catch (IOException e) { // swallow IOException. Smth went wrong before this and we're much more interested in that error string msg = String.Format("warning: Something went wrong while cleaning file after internal error (See below).\n Can't cleanup files because of IOException:\n{0}\n", e.IndentExceptionMessage()); Trace.WriteLine(msg); } catch (UnauthorizedAccessException e) { // swallow it also string msg = String.Format("warning: Something went wrong while cleaning file after internal error (See below).\n Can't cleanup files because of UnauthorizedAccessException:\n{0}\n", e.IndentExceptionMessage()); Trace.WriteLine(msg); } } throw; } bool errorOccurs = false; try { if (withBranches && initBranch != null) { fetch.IgnoreBranches = false; } if (tfsRepositoryPath == GitTfsConstants.TfsRoot) { fetch.IgnoreBranches = true; } if (retVal == 0) { fetch.Run(withBranches); globals.Repository.GarbageCollect(); } if (withBranches && initBranch != null) { initBranch.CloneAllBranches = true; retVal = initBranch.Run(); } } catch (GitTfsException) { errorOccurs = true; throw; } catch (Exception ex) { errorOccurs = true; throw new GitTfsException("error: a problem occured when trying to clone the repository. Try to solve the problem described below.\nIn any case, after, try to continue using command `git tfs " + (withBranches ? "branch init --all" : "fetch") + "`\n", ex); } finally { try { if (!init.IsBare) { globals.Repository.Merge(globals.Repository.ReadTfsRemote(globals.RemoteId).RemoteRef); } } catch (Exception) { //Swallow exception because the previously thrown exception is more important... if (!errorOccurs) { throw; } } } return(retVal); }