protected SemanticVersion FindVersion( GitVersionContext context, BranchType branchType) { var ancestor = FindCommonAncestorWithDevelop(context.Repository, context.CurrentBranch, branchType); if (!IsThereAnyCommitOnTheBranch(context.Repository, context.CurrentBranch)) { var developVersionFinder = new DevelopVersionFinder(); return(developVersionFinder.FindVersion(context)); } var versionOnMasterFinder = new VersionOnMasterFinder(); var versionFromMaster = versionOnMasterFinder.Execute(context, context.CurrentCommit.When()); var numberOfCommitsOnBranchSinceCommit = NumberOfCommitsOnBranchSinceCommit(context, ancestor); var preReleaseTag = context.CurrentBranch.Name .TrimStart(branchType.ToString() + '-') .TrimStart(branchType.ToString() + '/'); var semanticVersion = new SemanticVersion { Major = versionFromMaster.Major, Minor = versionFromMaster.Minor + 1, Patch = 0, PreReleaseTag = preReleaseTag, BuildMetaData = new SemanticVersionBuildMetaData( numberOfCommitsOnBranchSinceCommit, context.CurrentBranch.Name, context.CurrentCommit.Sha, context.CurrentCommit.When()) }; semanticVersion.OverrideVersionManuallyIfNeeded(context.Repository, context.Configuration); return(semanticVersion); }
public SemanticVersion FindVersion(GitVersionContext context) { var versionOnMasterFinder = new VersionOnMasterFinder(); var tip = context.CurrentCommit; var versionFromMaster = versionOnMasterFinder.Execute(context, tip.When()); var f = new CommitFilter { Since = tip, Until = context.Repository.FindBranch("master").Tip, SortBy = CommitSortStrategies.Topological | CommitSortStrategies.Time }; var c = context.Repository.Commits.QueryBy(f); var numberOfCommitsSinceRelease = c.Count(); var semanticVersion = new SemanticVersion { Major = versionFromMaster.Major, Minor = versionFromMaster.Minor + 1, Patch = 0, PreReleaseTag = context.Configuration.DevelopBranchTag + numberOfCommitsSinceRelease, BuildMetaData = new SemanticVersionBuildMetaData(numberOfCommitsSinceRelease, context.CurrentBranch.Name,tip.Sha,tip.When()), }; semanticVersion.OverrideVersionManuallyIfNeeded(context.Repository, context.Configuration); return semanticVersion; }
public SemanticVersion FindVersion(GitVersionContext context) { var versionOnMasterFinder = new VersionOnMasterFinder(); var tip = context.CurrentBranch.Tip; var versionFromMaster = versionOnMasterFinder.Execute(context, tip.When()); var f = new CommitFilter { Since = tip, Until = context.Repository.FindBranch("master").Tip, SortBy = CommitSortStrategies.Topological | CommitSortStrategies.Time }; var c = context.Repository.Commits.QueryBy(f); var numberOfCommitsSinceRelease = c.Count(); var releaseDate = ReleaseDateFinder.Execute(context.Repository, tip.Sha, 0); var semanticVersion = new SemanticVersion { Major = versionFromMaster.Major, Minor = versionFromMaster.Minor + 1, Patch = 0, PreReleaseTag = "unstable" + numberOfCommitsSinceRelease, BuildMetaData = new SemanticVersionBuildMetaData(numberOfCommitsSinceRelease, context.CurrentBranch.Name, releaseDate), }; return semanticVersion; }
protected SemanticVersion FindVersion( GitVersionContext context, BranchType branchType) { var ancestor = FindCommonAncestorWithDevelop(context.Repository, context.CurrentBranch, branchType); if (!IsThereAnyCommitOnTheBranch(context.Repository, context.CurrentBranch)) { var developVersionFinder = new DevelopVersionFinder(); return developVersionFinder.FindVersion(context); } var versionOnMasterFinder = new VersionOnMasterFinder(); var versionFromMaster = versionOnMasterFinder.Execute(context, context.CurrentBranch.Tip.Committer.When); var numberOfCommitsOnBranchSinceCommit = NumberOfCommitsOnBranchSinceCommit(context, ancestor); var sha = context.CurrentBranch.Tip.Sha; var releaseDate = ReleaseDateFinder.Execute(context.Repository, sha, 0); var semanticVersion = new SemanticVersion { Major = versionFromMaster.Major, Minor = versionFromMaster.Minor + 1, Patch = 0, PreReleaseTag = "unstable0", BuildMetaData = new SemanticVersionBuildMetaData( numberOfCommitsOnBranchSinceCommit, context.CurrentBranch.Name, releaseDate) }; return semanticVersion; }
public SemanticVersion FindVersion(GitVersionContext context) { var versionOnMasterFinder = new VersionOnMasterFinder(); var tip = context.CurrentCommit; var versionFromMaster = versionOnMasterFinder.Execute(context, tip.When()); var f = new CommitFilter { Since = tip, Until = context.Repository.FindBranch("master").Tip, SortBy = CommitSortStrategies.Topological | CommitSortStrategies.Time }; var c = context.Repository.Commits.QueryBy(f); var numberOfCommitsSinceRelease = c.Count(); var semanticVersion = new SemanticVersion { Major = versionFromMaster.Major, Minor = versionFromMaster.Minor + 1, Patch = 0, PreReleaseTag = context.Configuration.DevelopBranchTag + numberOfCommitsSinceRelease, BuildMetaData = new SemanticVersionBuildMetaData(numberOfCommitsSinceRelease, context.CurrentBranch.Name, tip.Sha, tip.When()), }; semanticVersion.OverrideVersionManuallyIfNeeded(context.Repository, context.Configuration); return(semanticVersion); }
protected SemanticVersion FindVersion( GitVersionContext context, BranchType branchType) { var ancestor = FindCommonAncestorWithDevelop(context.Repository, context.CurrentBranch, branchType); if (!IsThereAnyCommitOnTheBranch(context.Repository, context.CurrentBranch)) { var developVersionFinder = new DevelopVersionFinder(); return(developVersionFinder.FindVersion(context)); } var versionOnMasterFinder = new VersionOnMasterFinder(); var versionFromMaster = versionOnMasterFinder.Execute(context, context.CurrentBranch.Tip.Committer.When); var numberOfCommitsOnBranchSinceCommit = NumberOfCommitsOnBranchSinceCommit(context, ancestor); var sha = context.CurrentBranch.Tip.Sha; var releaseDate = ReleaseDateFinder.Execute(context.Repository, sha, 0); var semanticVersion = new SemanticVersion { Major = versionFromMaster.Major, Minor = versionFromMaster.Minor + 1, Patch = 0, PreReleaseTag = "unstable0", BuildMetaData = new SemanticVersionBuildMetaData( numberOfCommitsOnBranchSinceCommit, context.CurrentBranch.Name, releaseDate) }; return(semanticVersion); }
protected SemanticVersion FindVersion( GitVersionContext context, BranchType branchType) { var ancestor = FindCommonAncestorWithDevelop(context.Repository, context.CurrentBranch, branchType); if (!IsThereAnyCommitOnTheBranch(context.Repository, context.CurrentBranch)) { var developVersionFinder = new DevelopVersionFinder(); return developVersionFinder.FindVersion(context); } var versionOnMasterFinder = new VersionOnMasterFinder(); var versionFromMaster = versionOnMasterFinder.Execute(context, context.CurrentCommit.When()); var numberOfCommitsOnBranchSinceCommit = NumberOfCommitsOnBranchSinceCommit(context, ancestor); var preReleaseTag = context.CurrentBranch.Name .TrimStart(branchType.ToString() + '-') .TrimStart(branchType.ToString() + '/'); var semanticVersion = new SemanticVersion { Major = versionFromMaster.Major, Minor = versionFromMaster.Minor + 1, Patch = 0, PreReleaseTag = preReleaseTag, BuildMetaData = new SemanticVersionBuildMetaData( numberOfCommitsOnBranchSinceCommit, context.CurrentBranch.Name, context.CurrentCommit.Sha, context.CurrentCommit.When()) }; semanticVersion.OverrideVersionManuallyIfNeeded(context.Repository, context.Configuration); return semanticVersion; }
public SemanticVersion FindVersion(GitVersionContext context) { var versionOnMasterFinder = new VersionOnMasterFinder(); var tip = context.CurrentBranch.Tip; var versionFromMaster = versionOnMasterFinder.Execute(context, tip.When()); var f = new CommitFilter { Since = tip, Until = context.Repository.FindBranch("master").Tip, SortBy = CommitSortStrategies.Topological | CommitSortStrategies.Time }; var c = context.Repository.Commits.QueryBy(f); var numberOfCommitsSinceRelease = c.Count(); var releaseDate = ReleaseDateFinder.Execute(context.Repository, tip.Sha, 0); var semanticVersion = new SemanticVersion { Major = versionFromMaster.Major, Minor = versionFromMaster.Minor + 1, Patch = 0, PreReleaseTag = "unstable" + numberOfCommitsSinceRelease, BuildMetaData = new SemanticVersionBuildMetaData(numberOfCommitsSinceRelease, context.CurrentBranch.Name, releaseDate), }; return(semanticVersion); }
public void Should_find_previous_commit_that_was_at_least_a_minor_bump() { var finder = new VersionOnMasterFinder(); var dateTime = new DateTimeOffset(2000, 10, 10,0,0,0,new TimeSpan(0)); var signature = 2.Seconds().Before(dateTime).ToSignature(); const string sha = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"; var version = finder.Execute(new GitVersionContext { Repository = new MockRepository { Branches = new MockBranchCollection { new MockBranch("master") { new MockMergeCommit(new ObjectId(sha)) { MessageEx = "Merge branch 'hotfix-0.3.0'", CommitterEx = signature }, new MockMergeCommit { MessageEx = "Merge branch 'hotfix-0.3.1'", CommitterEx = signature, }, new MockMergeCommit { MessageEx = "Merge branch 'hotfix-0.2.0'", CommitterEx = signature }, }, } } }, 1.Seconds().Ago()); ObjectApprover.VerifyWithJson(version); }