Introduce --allow-stream-branches

This commit is contained in:
Mustafa Gezen 2021-04-27 19:14:01 +02:00
parent f92efe75b6
commit 8fdc3a98e1
3 changed files with 10 additions and 1 deletions

View File

@ -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)

View File

@ -50,5 +50,6 @@ type ProcessData struct {
ManualCommits []string
UpstreamPrefixHttps string
ModuleFallbackStream string
AllowStreamBranches bool
FsCreator func(branch string) billy.Filesystem
}

View File

@ -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{}