static AbcVersion CalculateVersion(AbcVersion baseVersion, AbcVersionGitSubData data, Config config) { var branch = data.GitBranch; if (config.Branches.ContainsKey(branch)) { var configBranch = config.Branches[branch]; var firstParentNumber = GitTool.GetCommitNumberCurrentBranchFirstParent(configBranch.ParentSha); var sem = SemVersion.Parse(configBranch.Version); var patchNewValue = sem.Patch + firstParentNumber - 1; var pathNewValue2 = patchNewValue < 0 ? 0 : patchNewValue; var simple = new AbcVersionSimple(sem.Major, sem.Minor, pathNewValue2, baseVersion.Special, baseVersion.BuildCounter, baseVersion.DateTime, baseVersion.Env); return(new AbcVersion(data, simple)); } else { var firstParentNumber = data.GitCommitsCurrentBranchFirstParent; var simple = new AbcVersionSimple(baseVersion.Major, baseVersion.Minor, firstParentNumber, baseVersion.Special, baseVersion.BuildCounter, baseVersion.DateTime, baseVersion.Env); return(new AbcVersion(data, simple)); } }
public AbcVersion(AbcVersionGitSubData gitData) { GitSha = gitData.GitSha; GitCommitsAll = gitData.GitCommitsAll; GitCommitsCurrentBranch = gitData.GitCommitsCurrentBranch; GitCommitsCurrentBranchFirstParent = gitData.GitCommitsCurrentBranchFirstParent; GitBranch = gitData.GitBranch; }
public AbcVersion(AbcVersionGitSubData gitData, AbcVersionSimple simple) : this(gitData) { Major = simple.Major; Minor = simple.Minor; Patch = simple.Patch; BuildCounter = simple.BuildCounter; Special = simple.Special; DateTime = simple.DateUtc; Env = simple.Env; }
public static AbcVersionGitSubData GetAllGitData() { var hash = GetHash(); var commitNumber = GetCommitNumberAll(); var commitNumberCurrentBranch = GetCommitNumberCurrentBranch(); var commitNumberCurrentBranchFirstParent = GetCommitNumberCurrentBranchFirstParent(); var branch = GetBranch(); var ret = new AbcVersionGitSubData(hash, commitNumber, branch, commitNumberCurrentBranch, commitNumberCurrentBranchFirstParent); return(ret); }