private void CloneTheRepositoryAndGetOnTheDesiredBranch(string tempPath, GitDeploymentTarget gitDeploymentTarget) { ExecuteGitCommand(tempPath, string.Format("git clone {0} ./", gitDeploymentTarget.RepositoryUrl)); if (ExecuteGitCommand(tempPath, "git branch").Contains(gitDeploymentTarget.BranchName)) { ExecuteGitCommand(tempPath, string.Format("git checkout {0}", gitDeploymentTarget.BranchName)); } else { ExecuteGitCommand(tempPath, string.Format("git checkout -b {0}", gitDeploymentTarget.BranchName)); } }
public GitDeploymentResult Deploy(GitDeploymentTarget gitDeploymentTarget, string pathToGeneratedCode) { var tempPath = getWorkingFolderPath.GetPathToWorkingFolder() + this.GetType().Name + "Temp" + Path.DirectorySeparatorChar + Guid.NewGuid() + Path.DirectorySeparatorChar; fileSystem.CreateFolder(tempPath); CloneTheRepositoryAndGetOnTheDesiredBranch(tempPath, gitDeploymentTarget); fileSystem.CopyFolder(pathToGeneratedCode, tempPath); AddTheNewFilesAndCommitThem(tempPath); ExecuteGitCommand(tempPath, string.Format("git push origin {0}", gitDeploymentTarget.BranchName)); return(null); }