public static SimpleCommit FromCommit(Commit commit) { var result = new SimpleCommit(commit.Sha, commit.MessageShort, commit.Committer.When, commit.BumpsMajorVersion(), commit.BumpsMinorVersion()); return(result); }
SimpleVersion GetVersionInternal(SimpleCommit commit) { // We do this to avoid recursing too many stack frames if (_calculatedVersions.TryGetValue(commit, out var alreadyCalculatedVersion)) { return(alreadyCalculatedVersion); } var taggedVersion = commit .TaggedWithVersions .OrderByDescending(v => v) .FirstOrDefault(); if (taggedVersion != null) { return(taggedVersion); } var maxParentVersion = commit.Parents .Select(GetVersionInternal) .OrderByDescending(v => v) .FirstOrDefault() ?? new SimpleVersion(0, 0, 0); SimpleVersion version; if (commit.BumpsMajorVersion) { version = new SimpleVersion(maxParentVersion.Major + 1, 0, 0); } else if (commit.BumpsMinorVersion) { version = new SimpleVersion(maxParentVersion.Major, maxParentVersion.Minor + 1, 0); } else { version = new SimpleVersion(maxParentVersion.Major, maxParentVersion.Minor, maxParentVersion.Patch + 1); } _calculatedVersions[commit] = version; return(version); }
SimpleVersion GetVersion(SimpleCommit commit) { EnsureCacheIsPrimed(); return(GetVersionInternal(commit)); }
public void AddParent(SimpleCommit parent) { Parents.Add(parent); }