Feature/dependency pinning and update automation (#5451)

* * handle local flag
* add managerfactory handling for local flag
* add shortName handling for local flag
* add dot git file handling for local flag
* add tests

* fix normal listing

* add ParseGitRepository function, add viper, add testing for utils

* add latest tag logic, add auto pinning and auto fetching

* makke gorepomod list works with --local

* make pinning works with local flag, enable auto update on fork and non-fork repo

* fix: refactor to pass linter

* refactor code and fix comments

* edit README

* refactor code to pass linting

* refactor code

* refactor code and enable patch branch label

* ru add license

* fbackward compatibility for unpin
This commit is contained in:
Kurnianto Trilaksono
2024-01-17 05:34:56 +08:00
committed by GitHub
parent f3fedac429
commit ab519fdc13
18 changed files with 1189 additions and 88 deletions

View File

@@ -80,6 +80,16 @@ func (mgr *Manager) hasUnPinnedDeps(m misc.LaModule) string {
}
func (mgr *Manager) List() error {
// Auto-update local tags
gr := git.NewQuiet(mgr.AbsPath(), false, false)
for _, module := range mgr.modules {
releaseBranch := fmt.Sprintf("release-%s", module.ShortName())
_, err := gr.GetLatestTag(releaseBranch)
if err != nil {
return fmt.Errorf("failed getting latest tags for %s", module)
}
}
fmt.Printf(" src path: %s\n", mgr.dg.SrcPath())
fmt.Printf(" repo path: %s\n", mgr.RepoPath())
fmt.Printf(" remote: %s\n", mgr.remoteName)
@@ -113,8 +123,8 @@ func determineBranchAndTag(
string(m.ShortName()) + "/" + v.String()
}
func (mgr *Manager) Debug(_ misc.LaModule, doIt bool) error {
gr := git.NewLoud(mgr.AbsPath(), doIt)
func (mgr *Manager) Debug(_ misc.LaModule, doIt bool, localFlag bool) error {
gr := git.NewLoud(mgr.AbsPath(), doIt, localFlag)
return gr.Debug(mgr.remoteName)
}
@@ -122,10 +132,8 @@ func (mgr *Manager) Debug(_ misc.LaModule, doIt bool) error {
//
// * All development happens in the branch named "master".
// * Each minor release gets its own branch.
//
func (mgr *Manager) Release(
target misc.LaModule, bump semver.SvBump, doIt bool) error {
target misc.LaModule, bump semver.SvBump, doIt bool, localFlag bool) error {
if reps := target.GetDisallowedReplacements(
mgr.allowedReplacements); len(reps) > 0 {
return fmt.Errorf(
@@ -145,7 +153,7 @@ func (mgr *Manager) Release(
newVersion, target.VersionRemote())
}
gr := git.NewLoud(mgr.AbsPath(), doIt)
gr := git.NewLoud(mgr.AbsPath(), doIt, localFlag)
relBranch, relTag := determineBranchAndTag(target, newVersion)
@@ -189,14 +197,14 @@ func (mgr *Manager) Release(
return nil
}
func (mgr *Manager) UnRelease(target misc.LaModule, doIt bool) error {
func (mgr *Manager) UnRelease(target misc.LaModule, doIt bool, localFlag bool) error {
fmt.Printf(
"Unreleasing %s/%s\n",
target.ShortName(), target.VersionRemote())
_, tag := determineBranchAndTag(target, target.VersionRemote())
gr := git.NewLoud(mgr.AbsPath(), doIt)
gr := git.NewLoud(mgr.AbsPath(), doIt, localFlag)
if err := gr.DeleteTagFromRemote(mgr.remoteName, tag); err != nil {
return err