Add support for version/release based fetching
This commit is contained in:
parent
f7017a9eac
commit
8199a79889
|
@ -54,6 +54,8 @@ var (
|
||||||
strictBranchMode bool
|
strictBranchMode bool
|
||||||
basicUsername string
|
basicUsername string
|
||||||
basicPassword string
|
basicPassword string
|
||||||
|
packageVersion string
|
||||||
|
packageRelease string
|
||||||
)
|
)
|
||||||
|
|
||||||
var root = &cobra.Command{
|
var root = &cobra.Command{
|
||||||
|
@ -88,6 +90,8 @@ func mn(_ *cobra.Command, _ []string) {
|
||||||
CdnUrl: cdnUrl,
|
CdnUrl: cdnUrl,
|
||||||
HttpUsername: basicUsername,
|
HttpUsername: basicUsername,
|
||||||
HttpPassword: basicPassword,
|
HttpPassword: basicPassword,
|
||||||
|
PackageVersion: packageVersion,
|
||||||
|
PackageRelease: packageRelease,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
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().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(&basicUsername, "basic-username", "", "Basic auth username")
|
||||||
root.Flags().StringVar(&basicPassword, "basic-password", "", "Basic auth password")
|
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 {
|
if err := root.Execute(); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
|
|
@ -55,4 +55,6 @@ type ProcessData struct {
|
||||||
FsCreator FsCreatorFunc
|
FsCreator FsCreatorFunc
|
||||||
CdnUrl string
|
CdnUrl string
|
||||||
Log *log.Logger
|
Log *log.Logger
|
||||||
|
PackageVersion string
|
||||||
|
PackageRelease string
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package misc
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/rocky-linux/srpmproc/pkg/data"
|
"github.com/rocky-linux/srpmproc/pkg/data"
|
||||||
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -13,7 +14,20 @@ func GetTagImportRegex(pd *data.ProcessData) *regexp.Regexp {
|
||||||
} else {
|
} else {
|
||||||
branchRegex += "(?:-stream-.+|)"
|
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)
|
return regexp.MustCompile(regex)
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,6 +93,9 @@ type ProcessDataRequest struct {
|
||||||
SingleTag string
|
SingleTag string
|
||||||
CdnUrl string
|
CdnUrl string
|
||||||
LogWriter io.Writer
|
LogWriter io.Writer
|
||||||
|
|
||||||
|
PackageVersion string
|
||||||
|
PackageRelease string
|
||||||
}
|
}
|
||||||
|
|
||||||
func gitlabify(str string) string {
|
func gitlabify(str string) string {
|
||||||
|
@ -258,6 +261,8 @@ func NewProcessData(req *ProcessDataRequest) (*data.ProcessData, error) {
|
||||||
FsCreator: fsCreator,
|
FsCreator: fsCreator,
|
||||||
CdnUrl: req.CdnUrl,
|
CdnUrl: req.CdnUrl,
|
||||||
Log: logger,
|
Log: logger,
|
||||||
|
PackageVersion: req.PackageVersion,
|
||||||
|
PackageRelease: req.PackageRelease,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue