Skip to content

Commit

Permalink
Merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
johnatasr committed Jul 23, 2023
2 parents 06cc3fe + 3f1a287 commit a483c34
Show file tree
Hide file tree
Showing 5 changed files with 283 additions and 127 deletions.
11 changes: 6 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ _testmain.go
.idea
*.iml

cmd/gen_release_notes/bin/*
cmd/backport/bin/*
cmd/standup/bin/*
cmd/k3s_release/bin/*
cmd/test-coverage/bin/*
cmd/gen_release_report/bin
cmd/gen_release_notes/bin
cmd/backport/bin
cmd/standup/bin
cmd/k3s_release/bin
cmd/test_coverage/bin

data/*

Expand Down
7 changes: 6 additions & 1 deletion cmd/backport/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# backport

The backport utility will create backport issues and perform a cherry-pick of the given commits to the given branches, if commits are provided on the CLI. If no commits are given, only the backport issues are created.

### Examples

```sh
# Backport K3s change into release-1.21 and release-1.22
# Backport K3s change into release-1.21 and release-1.22. Only create the backport issues.
./backport -r k3s -b 'release-1.21,release-1.22' -i 123

# Backport K3s change into release-1.21 and release-1.22. Creates the backport issues and cherry-picks the given commit id.
./backport -r k3s -b 'release-1.21,release-1.22' -i 123 -c '181210f8f9c779c26da1d9b2075bde0127302ee0'

# Backport RKE2 change into release-1.20, release-1.21 and release-1.22
Expand Down
30 changes: 13 additions & 17 deletions cmd/backport/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"flag"
"fmt"
"os"
"strings"

"github.com/rancher/ecm-distro-tools/repository"
)
Expand All @@ -24,26 +25,21 @@ Options:
-v show version and exit
-r repo repository that should be used
-i issue id original issue id
-c commit commit id that is being backported
-c commits commits to be backported (comma seperated)
-b branch(es) branches issue is being backported to
Examples:
# generate 2 backport issues for k3s issue 1234
%[2]s -r k3s -b "release-1.21,release-1.22" -i 1234 -c 1
%[2]s -r k3s -b "release-1.26" -i 1234 -c 1,2,3
`

const (
issueTitle = "[%s] - %s"
issueBody = "Backport fix for %s\n\n* #%d"
)

var (
vers bool
debug bool
repo string
commitID string
issueID uint
branches string
vers bool
repo string
commitIDs string
issueID uint
branches string
)

func main() {
Expand All @@ -60,7 +56,7 @@ func main() {

flag.BoolVar(&vers, "v", false, "")
flag.StringVar(&repo, "r", "", "")
flag.StringVar(&commitID, "c", "", "")
flag.StringVar(&commitIDs, "c", "", "")
flag.UintVar(&issueID, "i", 0, "")
flag.StringVar(&branches, "b", "", "")
flag.Parse()
Expand All @@ -76,9 +72,9 @@ func main() {
os.Exit(1)
}

if commitID == "" {
fmt.Println("error: please provide a commit id")
os.Exit(1)
var commits []string
if commitIDs != "" {
commits = strings.Split(commitIDs, ",")
}

if issueID == 0 {
Expand All @@ -92,7 +88,7 @@ func main() {

pbo := repository.PerformBackportOpts{
Repo: repo,
CommitID: commitID,
Commits: commits,
IssueID: issueID,
Branches: branches,
}
Expand Down
Loading

0 comments on commit a483c34

Please sign in to comment.