Ejemplo n.º 1
0
 private string GetBranch()
 {
     return
         (AppVeyor.Instance?.RepositoryBranch ??
          Bitrise.Instance?.GitBranch ??
          GitLab.Instance?.CommitRefName ??
          Jenkins.Instance?.GitBranch ??
          TeamCity.Instance?.BranchName ??
          TeamServices.Instance?.SourceBranchName ??
          Travis.Instance?.Branch ??
          GitTasks.GitCurrentBranch());
 }
Ejemplo n.º 2
0
 private string GetBranch()
 {
     return
         (AppVeyor.Instance?.RepositoryBranch ??
          Bitrise.Instance?.GitBranch ??
          GitLab.Instance?.CommitRefName ??
          Jenkins.Instance?.GitBranch ??
          Jenkins.Instance?.BranchName ??
          TeamCity.Instance?.BranchName ??
          AzurePipelines.Instance?.SourceBranchName ??
          TravisCI.Instance?.Branch ??
          GitHubActions.Instance?.GitHubRef ??
          GitTasks.GitCurrentBranch());
 }
        VersionInfo?GetFromGit()
        {
            if (!GitTasks.GitIsDetached())
            {
                var commitCount = GitTasks.Git("rev-list HEAD --count", logOutput: false).Select(x => x.Text).Single();
                var branch      = GitTasks.GitCurrentBranch()?.Replace("refs/heads/", "").Replace("/", "-");
                var revision    = GitTasks.Git("rev-parse HEAD", logOutput: false).Select(x => x.Text).Single();

                if (!string.IsNullOrEmpty(commitCount) && !string.IsNullOrEmpty(branch) && !string.IsNullOrEmpty(revision))
                {
                    return(new VersionInfo(
                               $"{VersionMajor}.{VersionMinor}.{commitCount}.0",
                               $"{VersionMajor}.{VersionMinor}.{commitCount}.0",
                               $"{VersionMajor}.{VersionMinor}.{commitCount}.0+Branch.{branch}.Sha.{revision}",
                               IsMainBranch(branch)
                            ? $"{VersionMajor}.{VersionMinor}.{commitCount}"
                            : $"{VersionMajor}.{VersionMinor}.{commitCount}-{branch}"));
                }
            }

            return(null);
        }