diff --git a/README.md b/README.md index c326798..6db1eb6 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,11 @@ Available Commands: help Help about any command Flags: - --allow-stream-branches Allow import from stream branches + --basic-password string Basic auth password + --basic-username string Basic auth username --branch-prefix string Branch prefix (replaces import-branch-prefix) (default "r") + --branch-suffix string Branch suffix to use for imported branches + --cdn-url string CDN URL to download blobs from (default "https://git.centos.org/sources") --git-committer-email string Email of committer (default "rockyautomation@rockylinux.org") --git-committer-name string Name of committer (default "rockyautomation") -h, --help help for srpmproc @@ -31,9 +34,9 @@ Flags: --ssh-key-location string Location of the SSH key to use to authenticate against upstream --ssh-user string SSH User (default "git") --storage-addr string Bucket to use as blob storage + --strict-branch-mode If enabled, only branches with the calculated name are imported and not prefix only --tmpfs-mode string If set, packages are imported to path and patched but not pushed --upstream-prefix string Upstream git repository prefix - --upstream-prefix-https string Web version of upstream prefix. Required if module-mode --version int Upstream version Use "srpmproc [command] --help" for more information about a command. diff --git a/pkg/srpmproc/patch.go b/pkg/srpmproc/patch.go index 0ad274b..b2ada0d 100644 --- a/pkg/srpmproc/patch.go +++ b/pkg/srpmproc/patch.go @@ -23,6 +23,7 @@ package srpmproc import ( "encoding/json" "fmt" + "github.com/go-git/go-git/v5/plumbing/transport" "github.com/rocky-linux/srpmproc/pkg/misc" "io/ioutil" "log" @@ -141,37 +142,47 @@ func executePatchesRpm(pd *data.ProcessData, md *data.ModeData) error { pd.Log.Printf("set reference to ref: %s", refName) if err != nil { - // no patches active - log.Println("info: patch repo not found") - return nil - } else { - err = w.Checkout(&git.CheckoutOptions{ - Branch: plumbing.NewRemoteReferenceName("origin", "main"), - Force: true, - }) - // common patches found, apply them - if err == nil { - err := applyPatches(pd, md, w, md.Worktree) + if err == transport.ErrInvalidAuthMethod || err == transport.ErrAuthenticationRequired { + fetchOptions.Auth = nil + err = repo.Fetch(fetchOptions) if err != nil { - return err + // no patches active + log.Println("info: patch repo not found") + return nil } } else { - log.Println("info: no common patches found") + // no patches active + log.Println("info: patch repo not found") + return nil } + } - err = w.Checkout(&git.CheckoutOptions{ - Branch: plumbing.NewRemoteReferenceName("origin", md.PushBranch), - Force: true, - }) - // branch specific patches found, apply them - if err == nil { - err := applyPatches(pd, md, w, md.Worktree) - if err != nil { - return err - } - } else { - log.Println("info: no branch specific patches found") + err = w.Checkout(&git.CheckoutOptions{ + Branch: plumbing.NewRemoteReferenceName("origin", "main"), + Force: true, + }) + // common patches found, apply them + if err == nil { + err := applyPatches(pd, md, w, md.Worktree) + if err != nil { + return err } + } else { + log.Println("info: no common patches found") + } + + err = w.Checkout(&git.CheckoutOptions{ + Branch: plumbing.NewRemoteReferenceName("origin", md.PushBranch), + Force: true, + }) + // branch specific patches found, apply them + if err == nil { + err := applyPatches(pd, md, w, md.Worktree) + if err != nil { + return err + } + } else { + log.Println("info: no branch specific patches found") } return nil