本文整理匯總了Golang中github.com/salsaflow/salsaflow/version.Version.ToTrunkVersion方法的典型用法代碼示例。如果您正苦於以下問題:Golang Version.ToTrunkVersion方法的具體用法?Golang Version.ToTrunkVersion怎麽用?Golang Version.ToTrunkVersion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/salsaflow/salsaflow/version.Version
的用法示例。
在下文中一共展示了Version.ToTrunkVersion方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: runMain
func runMain() (err error) {
// Load repo config.
gitConfig, err := git.LoadConfig()
if err != nil {
return err
}
var (
remote = gitConfig.RemoteName
trunkBranch = gitConfig.TrunkBranchName
releaseBranch = gitConfig.ReleaseBranchName
stagingBranch = gitConfig.StagingBranchName
)
// Fetch the remote repository.
if !flagNoFetch {
task := "Fetch the remote repository"
log.Run(task)
if err := git.UpdateRemotes(remote); err != nil {
return errs.NewError(task, err)
}
}
// Make sure trunk is up to date.
task := fmt.Sprintf("Make sure that branch '%v' is up to date", trunkBranch)
if err := git.CheckOrCreateTrackingBranch(trunkBranch, remote); err != nil {
return errs.NewError(task, err)
}
// Make sure the staging branch is up to date, in case it exists.
//
// We check stage here as well since it is otherwise checked later
// in releases.ListNewTrunkCommits(), which is usually called in
// release.PromptUserToConfirmStart().
task = fmt.Sprintf("Make sure that branch '%v' is up to date", stagingBranch)
if err := git.CheckOrCreateTrackingBranch(stagingBranch, remote); err != nil {
// The staging branch actually doesn't need to exist.
if _, ok := err.(*git.ErrRefNotFound); !ok {
return errs.NewError(task, err)
}
}
// Make sure that the release branch does not exist.
task = fmt.Sprintf("Make sure that branch '%v' does not exist", releaseBranch)
if err := git.EnsureBranchNotExist(releaseBranch, remote); err != nil {
return errs.NewError(task, err)
}
// Get the current trunk version string.
task = "Get the current trunk version string"
trunkVersion, err := version.GetByBranch(trunkBranch)
if err != nil {
return errs.NewError(task, err)
}
// Get the next trunk version (the future release version).
var nextTrunkVersion *version.Version
if !flagNextTrunk.Zero() {
// Make sure it's only major, minor and patch that are set.
// Make sure the new version is actually incrementing the current one.
var (
current = trunkVersion
next = flagNextTrunk
)
var part string
switch {
case len(next.Pre) != 0:
part = "Pre"
case len(next.Build) != 0:
part = "Build"
}
if part != "" {
return fmt.Errorf("invalid future version string: %v version part cannot be set", part)
}
if current.GE(next.Version) {
return fmt.Errorf("future version string not an increment: %v <= %v", next, current)
}
nextTrunkVersion = &flagNextTrunk
} else {
nextTrunkVersion = trunkVersion.IncrementMinor()
}
// Make sure the next trunk version has the right format.
nextTrunkVersion, err = nextTrunkVersion.ToTrunkVersion()
if err != nil {
return err
}
// Fetch the stories from the issue tracker.
tracker, err := modules.GetIssueTracker()
if err != nil {
return errs.NewError(task, err)
}
release := tracker.NextRelease(trunkVersion, nextTrunkVersion)
// Prompt the user to confirm the release.
fmt.Printf(`
You are about to start a new release branch.
//.........這裏部分代碼省略.........