diff --git a/cmd/srpmproc/main.go b/cmd/srpmproc/main.go index 0a657cf..38be0da 100644 --- a/cmd/srpmproc/main.go +++ b/cmd/srpmproc/main.go @@ -54,6 +54,8 @@ var ( strictBranchMode bool basicUsername string basicPassword string + packageVersion string + packageRelease string ) var root = &cobra.Command{ @@ -88,6 +90,8 @@ func mn(_ *cobra.Command, _ []string) { CdnUrl: cdnUrl, HttpUsername: basicUsername, HttpPassword: basicPassword, + PackageVersion: packageVersion, + PackageRelease: packageRelease, }) if err != nil { log.Fatal(err) @@ -136,6 +140,8 @@ func main() { root.Flags().BoolVar(&strictBranchMode, "strict-branch-mode", false, "If enabled, only branches with the calculated name are imported and not prefix only") root.Flags().StringVar(&basicUsername, "basic-username", "", "Basic auth username") root.Flags().StringVar(&basicPassword, "basic-password", "", "Basic auth password") + root.Flags().StringVar(&packageVersion, "package-version", "", "Package version to fetch") + root.Flags().StringVar(&packageRelease, "package-release", "", "Package release to fetch") if err := root.Execute(); err != nil { log.Fatal(err) diff --git a/pkg/data/process.go b/pkg/data/process.go index 1b6f484..bbfd694 100644 --- a/pkg/data/process.go +++ b/pkg/data/process.go @@ -55,4 +55,6 @@ type ProcessData struct { FsCreator FsCreatorFunc CdnUrl string Log *log.Logger + PackageVersion string + PackageRelease string } diff --git a/pkg/misc/regex.go b/pkg/misc/regex.go index 6de142f..411fae0 100644 --- a/pkg/misc/regex.go +++ b/pkg/misc/regex.go @@ -3,6 +3,7 @@ package misc import ( "fmt" "github.com/rocky-linux/srpmproc/pkg/data" + "path/filepath" "regexp" ) @@ -13,7 +14,20 @@ func GetTagImportRegex(pd *data.ProcessData) *regexp.Regexp { } else { branchRegex += "(?:-stream-.+|)" } - regex := fmt.Sprintf("refs/tags/(imports/(%s)/(.*))", branchRegex) + + initialVerRegex := filepath.Base(pd.RpmLocation) + "-" + if pd.PackageVersion != "" { + initialVerRegex += pd.PackageVersion + "-" + } else { + initialVerRegex += ".+-" + } + if pd.PackageRelease != "" { + initialVerRegex += pd.PackageRelease + } else { + initialVerRegex += ".+" + } + + regex := fmt.Sprintf("refs/tags/(imports/(%s)/(%s))", branchRegex, initialVerRegex) return regexp.MustCompile(regex) } diff --git a/pkg/srpmproc/process.go b/pkg/srpmproc/process.go index 595c2ad..8f445bf 100644 --- a/pkg/srpmproc/process.go +++ b/pkg/srpmproc/process.go @@ -93,6 +93,9 @@ type ProcessDataRequest struct { SingleTag string CdnUrl string LogWriter io.Writer + + PackageVersion string + PackageRelease string } func gitlabify(str string) string { @@ -258,6 +261,8 @@ func NewProcessData(req *ProcessDataRequest) (*data.ProcessData, error) { FsCreator: fsCreator, CdnUrl: req.CdnUrl, Log: logger, + PackageVersion: req.PackageVersion, + PackageRelease: req.PackageRelease, }, nil }