diff --git a/cmd/srpmproc/main.go b/cmd/srpmproc/main.go index 5223002..f5ebfd4 100644 --- a/cmd/srpmproc/main.go +++ b/cmd/srpmproc/main.go @@ -63,6 +63,7 @@ var ( manualCommits string upstreamPrefixHttps string moduleFallbackStream string + allowStreamBranches bool ) var root = &cobra.Command{ @@ -168,6 +169,7 @@ func mn(_ *cobra.Command, _ []string) { ManualCommits: manualCs, UpstreamPrefixHttps: upstreamPrefixHttps, ModuleFallbackStream: moduleFallbackStream, + AllowStreamBranches: allowStreamBranches, FsCreator: fsCreator, }) } @@ -199,6 +201,7 @@ func main() { root.Flags().StringVar(&manualCommits, "manual-commits", "", "Comma separated branch and commit list for packages with broken release tags (Format: BRANCH:HASH)") root.Flags().StringVar(&upstreamPrefixHttps, "upstream-prefix-https", "", "Web version of upstream prefix. Required if module-mode") root.Flags().StringVar(&moduleFallbackStream, "module-fallback-stream", "", "Override fallback stream. Some module packages are published as collections and mostly use the same stream name, some of them deviate from the main stream") + root.Flags().BoolVar(&allowStreamBranches, "allow-stream-branches", false, "Allow import from stream branches") if err := root.Execute(); err != nil { log.Fatal(err) diff --git a/internal/data/process.go b/internal/data/process.go index 5a9ef15..cd8a540 100644 --- a/internal/data/process.go +++ b/internal/data/process.go @@ -50,5 +50,6 @@ type ProcessData struct { ManualCommits []string UpstreamPrefixHttps string ModuleFallbackStream string + AllowStreamBranches bool FsCreator func(branch string) billy.Filesystem } diff --git a/internal/process.go b/internal/process.go index 20a4288..d514774 100644 --- a/internal/process.go +++ b/internal/process.go @@ -59,7 +59,12 @@ func gitlabify(str string) string { // all files that are remote goes into .gitignore // all ignored files' hash goes into .{Name}.metadata func ProcessRPM(pd *data.ProcessData) { - tagImportRegex = regexp.MustCompile(fmt.Sprintf("refs/tags/(imports/(%s.|%s.-.+)/(.*))", pd.ImportBranchPrefix, pd.ImportBranchPrefix)) + if pd.AllowStreamBranches { + tagImportRegex = regexp.MustCompile(fmt.Sprintf("refs/tags/(imports/(%s(?:.s|.)|%s(?:|s).-.+)/(.*))", pd.ImportBranchPrefix, pd.ImportBranchPrefix)) + } else { + tagImportRegex = regexp.MustCompile(fmt.Sprintf("refs/tags/(imports/(%s.|%s.-.+)/(.*))", pd.ImportBranchPrefix, pd.ImportBranchPrefix)) + } + md := pd.Importer.RetrieveSource(pd) md.BlobCache = map[string][]byte{}