public void Clean(Dep dep) { log.LogInformation($"Start cleaning {dep.Name}"); ConsoleWriter.WriteProgress($"Cleaning {dep.Name}"); var command = "git clean -d -f -x"; // -d - remove whole directory // -f - force delete // -x - remove ignored files, too var exitCode = shellRunner.RunInDirectory(Path.Combine(Helper.CurrentWorkspace, dep.Name), command, TimeSpan.FromMinutes(1), RetryStrategy.None); if (exitCode != 0) { log.LogWarning($"'git clean' finished with non-zero exit code: '{exitCode}'"); ConsoleWriter.WriteInfo($"Could not clean {dep.Name}. Continue building without clean"); return; } log.LogInformation($"{dep.Name} was cleaned successfully"); ConsoleWriter.WriteOk($"{dep.Name} was cleaned successfully"); }
public CurrentTreeish CurrentLocalTreeish() { log.Info($"{"[" + ModuleName + "]",-30}Getting current treeish"); var exitCode = runner.RunInDirectory(RepoPath, "git rev-parse --abbrev-ref HEAD"); var output = runner.Output.Trim(); if (output != "HEAD") { return(new CurrentTreeish(TreeishType.Branch, output)); } if (exitCode != 0) { return(new CurrentTreeish(TreeishType.Branch, "master")); } runner.RunInDirectory(RepoPath, "git describe --tags --exact-match"); var tags = runner.Output.Trim(); if (tags.Length > 0) { return(new CurrentTreeish(TreeishType.Tag, tags)); } runner.RunInDirectory(RepoPath, "git rev-parse HEAD"); return(new CurrentTreeish(TreeishType.CommitHash, runner.Output.Trim())); }