Exemple #1
0
        protected static GitDetailModel BuildGitDetails(RepoPaths repoPaths, bool noCache)
        {
            var result = new GitDetailModel
            {
                Root = repoPaths.RootFolder,
                RelativePathToRoot = repoPaths.RelativePathToRoot
            };

            if (result.HasGit)
            {
                var configCmd = new GitConfigCommand(repoPaths, !noCache);
                var config    = configCmd.GetCommandResults();

                var statusCmd = new GitStatusCommand(repoPaths, !noCache);
                var status    = statusCmd.GetCommandResults();

                GetGitDir.TagRepoDir(config.RepoName, repoPaths.RootFolder);

                result.Branch     = GitUtils.Current.GetBranchName(repoPaths);
                result.User       = config?.User;
                result.Ahead      = (status?.Ahead) ?? 0;
                result.Behind     = (status?.Behind) ?? 0;
                result.Staged     = status?.Staged ?? 0;
                result.Unstaged   = status?.Unstaged ?? 0;
                result.IsDetached = status.Detached;
                result.DetachedAt = status.DetachedAt;

                result.FileChanges = status?.FileChanges;
            }

            return(result);
        }
Exemple #2
0
        protected override GitConfig BuildResponse()
        {
            if (string.IsNullOrEmpty(this.RepositoryDirectories.RepositoryFolder))
            {
                return(null);
            }

            var configCmd = new GitConfigCommand(this.RepositoryDirectories, !this.NoCache.IsPresent);
            var config    = configCmd.GetCommandResults();

            return(config);
        }