예제 #1
0
파일: Cleaner.cs 프로젝트: aidmsu/cement
        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");
        }
예제 #2
0
        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()));
        }