summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCasey Lee <cplee@nektos.com>2019-01-15 18:05:27 +0100
committerCasey Lee <cplee@nektos.com>2019-01-15 18:05:27 +0100
commit44e21b102e7c32574e2907d7703df68035cc8ca3 (patch)
tree9412a9384bc7a458d5d6ab8d916ad9a1d0f5f2f5
parentreadme update (diff)
downloadforgejo-act-44e21b102e7c32574e2907d7703df68035cc8ca3.tar.xz
forgejo-act-44e21b102e7c32574e2907d7703df68035cc8ca3.zip
resolve issue with reference a branch on a github actionv0.0.2
-rw-r--r--actions/runner_test.go1
-rw-r--r--common/git.go13
2 files changed, 10 insertions, 4 deletions
diff --git a/actions/runner_test.go b/actions/runner_test.go
index cb620ac..890eca1 100644
--- a/actions/runner_test.go
+++ b/actions/runner_test.go
@@ -73,6 +73,7 @@ func TestParseImageGithub(t *testing.T) {
{"nektos/act/foo", "https://github.com/nektos/act", "master", "foo", true},
{"nektos/act@xxxxx", "https://github.com/nektos/act", "xxxxx", ".", true},
{"nektos/act/bar/baz@zzzzz", "https://github.com/nektos/act", "zzzzz", "bar/baz", true},
+ {"assimovt/actions-github-deploy/github-deploy@deployment-status-metadata", "https://github.com/assimovt/actions-github-deploy", "deployment-status-metadata", "github-deploy", true},
{"nektos/zzzzundefinedzzzz", "", "", "", false},
}
diff --git a/common/git.go b/common/git.go
index 33063f9..549727b 100644
--- a/common/git.go
+++ b/common/git.go
@@ -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
}