retry fetching patch repo if the error is invalid auth method
This commit is contained in:
parent
bc9d81bd8e
commit
dd7fd31ebb
|
@ -12,8 +12,11 @@ Available Commands:
|
||||||
help Help about any command
|
help Help about any command
|
||||||
|
|
||||||
Flags:
|
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-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-email string Email of committer (default "rockyautomation@rockylinux.org")
|
||||||
--git-committer-name string Name of committer (default "rockyautomation")
|
--git-committer-name string Name of committer (default "rockyautomation")
|
||||||
-h, --help help for srpmproc
|
-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-key-location string Location of the SSH key to use to authenticate against upstream
|
||||||
--ssh-user string SSH User (default "git")
|
--ssh-user string SSH User (default "git")
|
||||||
--storage-addr string Bucket to use as blob storage
|
--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
|
--tmpfs-mode string If set, packages are imported to path and patched but not pushed
|
||||||
--upstream-prefix string Upstream git repository prefix
|
--upstream-prefix string Upstream git repository prefix
|
||||||
--upstream-prefix-https string Web version of upstream prefix. Required if module-mode
|
|
||||||
--version int Upstream version
|
--version int Upstream version
|
||||||
|
|
||||||
Use "srpmproc [command] --help" for more information about a command.
|
Use "srpmproc [command] --help" for more information about a command.
|
||||||
|
|
|
@ -23,6 +23,7 @@ package srpmproc
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/go-git/go-git/v5/plumbing/transport"
|
||||||
"github.com/rocky-linux/srpmproc/pkg/misc"
|
"github.com/rocky-linux/srpmproc/pkg/misc"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
|
@ -141,37 +142,47 @@ func executePatchesRpm(pd *data.ProcessData, md *data.ModeData) error {
|
||||||
pd.Log.Printf("set reference to ref: %s", refName)
|
pd.Log.Printf("set reference to ref: %s", refName)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// no patches active
|
if err == transport.ErrInvalidAuthMethod || err == transport.ErrAuthenticationRequired {
|
||||||
log.Println("info: patch repo not found")
|
fetchOptions.Auth = nil
|
||||||
return nil
|
err = repo.Fetch(fetchOptions)
|
||||||
} 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 != nil {
|
if err != nil {
|
||||||
return err
|
// no patches active
|
||||||
|
log.Println("info: patch repo not found")
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
} else {
|
} 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{
|
err = w.Checkout(&git.CheckoutOptions{
|
||||||
Branch: plumbing.NewRemoteReferenceName("origin", md.PushBranch),
|
Branch: plumbing.NewRemoteReferenceName("origin", "main"),
|
||||||
Force: true,
|
Force: true,
|
||||||
})
|
})
|
||||||
// branch specific patches found, apply them
|
// common patches found, apply them
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err := applyPatches(pd, md, w, md.Worktree)
|
err := applyPatches(pd, md, w, md.Worktree)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
|
||||||
} else {
|
|
||||||
log.Println("info: no branch specific patches found")
|
|
||||||
}
|
}
|
||||||
|
} 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
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue