Skip to content

Commit

Permalink
Add support for version/release based fetching
Browse files Browse the repository at this point in the history
  • Loading branch information
mstg committed May 5, 2022
1 parent f7017a9 commit 8199a79
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
6 changes: 6 additions & 0 deletions cmd/srpmproc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ var (
strictBranchMode bool
basicUsername string
basicPassword string
packageVersion string
packageRelease string
)

var root = &cobra.Command{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions pkg/data/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,6 @@ type ProcessData struct {
FsCreator FsCreatorFunc
CdnUrl string
Log *log.Logger
PackageVersion string
PackageRelease string
}
16 changes: 15 additions & 1 deletion pkg/misc/regex.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package misc
import (
"fmt"
"github.com/rocky-linux/srpmproc/pkg/data"
"path/filepath"
"regexp"
)

Expand All @@ -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)
}
5 changes: 5 additions & 0 deletions pkg/srpmproc/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ type ProcessDataRequest struct {
SingleTag string
CdnUrl string
LogWriter io.Writer

PackageVersion string
PackageRelease string
}

func gitlabify(str string) string {
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 8199a79

Please sign in to comment.