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

@@ -8,7 +8,9 @@ import (
"os"
"path/filepath"
"regexp"
"strings"
v "github.com/spf13/viper"
"golang.org/x/mod/modfile"
"sigs.k8s.io/kustomize/cmd/gorepomod/internal/misc"
"sigs.k8s.io/kustomize/cmd/gorepomod/internal/utils"
@@ -28,6 +30,13 @@ func (pm *protoModule) FullPath() string {
return pm.mf.Module.Mod.Path
}
func (pm *protoModule) FullLocalPath() string {
var localPrefix string = v.GetString("LocalGitPrefix")
var pathToModule string = pm.mf.Module.Mod.Path
pathSlice := strings.Split(pathToModule, "/")
return localPrefix + "/" + strings.Join(pathSlice[1:], "/")
}
func (pm *protoModule) PathToGoMod() string {
return pm.pathToGoMod
}
@@ -47,6 +56,19 @@ func (pm *protoModule) ShortName(
return misc.ModuleShortName(stripped)
}
func (pm *protoModule) ShortNameWithLocalFlag(
repoImportPath string) misc.ModuleShortName {
fp := pm.FullLocalPath()
if fp == repoImportPath {
return misc.ModuleAtTop
}
p := fp[len(repoImportPath)+2:]
stripped := trailingVersionPattern.ReplaceAllString(p, "")
pathSlice := strings.Split(stripped, "/")
return misc.ModuleShortName(strings.Join(pathSlice[3:], "/"))
}
func loadProtoModules(
repoRoot string, exclusions []string) (result []*protoModule, err error) {
var paths []string