mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-08-11 17:50:58 +00:00
resolve issue with reference a branch on a github action
This commit is contained in:
parent
957282b8bc
commit
2ebaaf0e8c
2 changed files with 10 additions and 4 deletions
|
@ -185,11 +185,14 @@ func NewGitCloneExecutor(input NewGitCloneExecutorInput) Executor {
|
|||
cloneLock.Lock()
|
||||
defer cloneLock.Unlock()
|
||||
|
||||
refName := plumbing.ReferenceName(fmt.Sprintf("refs/heads/%s", input.Ref))
|
||||
|
||||
r, err := git.PlainOpen(input.Dir)
|
||||
if err != nil {
|
||||
r, err = git.PlainClone(input.Dir, false, &git.CloneOptions{
|
||||
URL: input.URL.String(),
|
||||
Progress: input.Logger.WriterLevel(log.DebugLevel),
|
||||
URL: input.URL.String(),
|
||||
Progress: input.Logger.WriterLevel(log.DebugLevel),
|
||||
ReferenceName: refName,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -206,10 +209,12 @@ func NewGitCloneExecutor(input NewGitCloneExecutorInput) Executor {
|
|||
|
||||
err = w.Checkout(&git.CheckoutOptions{
|
||||
//Branch: plumbing.NewHash(ref),
|
||||
Hash: plumbing.NewHash(input.Ref),
|
||||
Branch: refName,
|
||||
//Hash: plumbing.NewHash(input.Ref),
|
||||
Force: true,
|
||||
})
|
||||
if err != nil {
|
||||
input.Logger.Error(err)
|
||||
input.Logger.Errorf("Unable to checkout %s: %v", refName, err)
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue