Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a flag --upstream-version to migrate a package to an other vers… #14

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cmd/srpmproc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var (
sshKeyLocation string
sshUser string
upstreamPrefix string
upstreamVersion int
version int
storageAddr string
gitCommitterName string
Expand Down Expand Up @@ -69,6 +70,7 @@ var root = &cobra.Command{
func mn(_ *cobra.Command, _ []string) {
pd, err := srpmproc.NewProcessData(&srpmproc.ProcessDataRequest{
Version: version,
UpstreamVersion: upstreamVersion,
StorageAddr: storageAddr,
Package: sourceRpm,
ModuleMode: moduleMode,
Expand Down Expand Up @@ -120,6 +122,8 @@ func main() {
_ = root.MarkFlagRequired("upstream-prefix")
root.Flags().IntVar(&version, "version", 0, "Upstream version")
_ = root.MarkFlagRequired("version")
root.Flags().IntVar(&upstreamVersion, "upstream-version", 0, "Upstream version")

root.Flags().StringVar(&storageAddr, "storage-addr", "", "Bucket to use as blob storage")
_ = root.MarkFlagRequired("storage-addr")

Expand Down
1 change: 1 addition & 0 deletions pkg/data/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type ProcessData struct {
RpmLocation string
UpstreamPrefix string
Version int
UpstreamVersion int
GitCommitterName string
GitCommitterEmail string
Mode int
Expand Down
10 changes: 8 additions & 2 deletions pkg/srpmproc/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const (
type ProcessDataRequest struct {
// Required
Version int
UpstreamVersion int
StorageAddr string
Package string

Expand Down Expand Up @@ -170,6 +171,9 @@ func NewProcessData(req *ProcessDataRequest) (*data.ProcessData, error) {
logger := log.New(writer, "", log.LstdFlags)

// Set defaults
if req.UpstreamVersion == 0 {
req.UpstreamVersion = req.Version
}
if req.ModulePrefix == "" {
req.ModulePrefix = ModulePrefixCentOS
}
Expand Down Expand Up @@ -311,6 +315,7 @@ func NewProcessData(req *ProcessDataRequest) (*data.ProcessData, error) {
RpmLocation: sourceRpmLocation,
UpstreamPrefix: req.UpstreamPrefix,
Version: req.Version,
UpstreamVersion: req.UpstreamVersion,
BlobStorage: blobStorage,
GitCommitterName: req.GitCommitterName,
GitCommitterEmail: req.GitCommitterEmail,
Expand Down Expand Up @@ -1344,7 +1349,7 @@ func taglessBranchName(fullBranch string, pd *data.ProcessData) string {

// Simple case: if our branch is not a modular stream branch, just return the normal <prefix><version><suffix> pattern
if !strings.HasPrefix(branch, "stream-") {
return fmt.Sprintf("%s%d%s", pd.BranchPrefix, pd.Version, pd.BranchSuffix)
return fmt.Sprintf("%s%d%s", pd.BranchPrefix, pd.UpstreamVersion, pd.BranchSuffix)
}

// index where the "-rhel-" starts near the end of the string
Expand All @@ -1357,5 +1362,6 @@ func taglessBranchName(fullBranch string, pd *data.ProcessData) string {
majorMinor := branch[rhelSpot+6:]

// return translated modular branch:
return fmt.Sprintf("%s%d%s-%s_%s", pd.BranchPrefix, pd.Version, pd.BranchSuffix, moduleString, majorMinor)

return fmt.Sprintf("%s%d%s-%s_%s", pd.BranchPrefix, pd.UpstreamVersion, pd.BranchSuffix, moduleString, majorMinor)
}