diff --git a/docs.md b/docs.md index 3734163..f75dcf0 100644 --- a/docs.md +++ b/docs.md @@ -56,8 +56,8 @@ clone: | `home` | | Change HOME var for commands executed, fail if it does not exist | | `remote` | $CI_REPO_CLONE_URL | Set the git remote url | | `remote-ssh` | $CI_REPO_CLONE_SSH_URL | Set the git SSH remote url | -| `sha` | $CI_COMMIT_SHA | git commit hash to retrieve (use `sha: ''` to clone the `ref`) | -| `ref` | $CI_COMMIT_REF | Set the git reference to retrieve (use `ref: refs/heads/a_branch` and `sha: ''` to retrieve the head commit from the "a_branch" branch) | +| `sha` | $CI_COMMIT_SHA | git commit hash to retrieve | +| `ref` | _none_ | Set the git reference to retrieve | | `path` | $CI_WORKSPACE | Set destination path to clone to | | `use-ssh` | `false` | Clone using SSH | | `ssh-key` | _none_ | SSH key for SSH clone | diff --git a/flags.go b/flags.go index 234a93b..8e17706 100644 --- a/flags.go +++ b/flags.go @@ -29,9 +29,8 @@ var globalFlags = []cli.Flag{ }, &cli.StringFlag{ Name: "ref", - Value: "refs/heads/master", Usage: "git commit ref", - EnvVars: []string{"PLUGIN_REF", "CI_COMMIT_REF"}, + EnvVars: []string{"PLUGIN_REF"}, }, &cli.StringFlag{ Name: "event", diff --git a/plugin.go b/plugin.go index 0664c51..23be46b 100644 --- a/plugin.go +++ b/plugin.go @@ -76,9 +76,9 @@ func (p Plugin) Exec() error { } - if p.Pipeline.Commit == "" { + if p.Pipeline.Ref != "" { // fetch and checkout by ref - fmt.Println("no commit information: using head checkout") + fmt.Println("using head checkout") cmds = append(cmds, fetch(p.Pipeline.Ref, p.Config.Tags, p.Config.Depth, p.Config.filter)) cmds = append(cmds, checkoutHead()) } else { diff --git a/plugin_test.go b/plugin_test.go index c86a297..1eaee6a 100644 --- a/plugin_test.go +++ b/plugin_test.go @@ -28,7 +28,7 @@ var commits = []struct { event: "push", branch: "master", commit: "553c2077f0edc3d5dc5d17262f6aa498e69d6f8e", - ref: "refs/heads/master", + ref: "", file: "README", data: "Hello World!", }, @@ -39,7 +39,7 @@ var commits = []struct { event: "push", branch: "master", commit: "7fd1a60b01f91b314f59955a4e4d4e80d8edf11d", - ref: "refs/heads/master", + ref: "", file: "README", data: "Hello World!\n", }, @@ -50,7 +50,7 @@ var commits = []struct { event: "pull_request", branch: "master", commit: "762941318ee16e59dabbacb1b4049eec22f0d303", - ref: "refs/pull/6/merge", + ref: "", file: "README", data: "Hello World!\n", }, @@ -61,7 +61,7 @@ var commits = []struct { event: "push", branch: "test", commit: "b3cbd5bbd7e81436d2eee04537ea2b4c0cad4cdf", - ref: "refs/heads/test", + ref: "", file: "CONTRIBUTING.md", data: "## Contributing\n", }, @@ -72,7 +72,7 @@ var commits = []struct { event: "tag", branch: "master", commit: "bf68d60215a167c935bc5976b7d06a7ffb290926", - ref: "refs/tags/v1.17", + ref: "", file: ".gitignore", data: "*.swp\n*~\n.rake_tasks~\nhtml\ndoc\npkg\npublish\ncoverage\n", }, @@ -83,7 +83,7 @@ var commits = []struct { event: "push", branch: "main", commit: "cc020eb6aaa601c13ca7b0d5db9d1ca694e7a003", - ref: "refs/heads/main", + ref: "", file: "Hello-World/README", data: "Hello World!\n", recursive: true, @@ -105,7 +105,7 @@ var commits = []struct { clone: "https://github.com/test-assets/woodpecker-git-test-lfs.git", event: "push", commit: "69d4dadb4c2899efb73c0095bb58a6454d133cef", - ref: "refs/heads/main", + ref: "", file: "4M.bin", dataSize: 132, }, @@ -115,7 +115,7 @@ var commits = []struct { clone: "https://github.com/test-assets/woodpecker-git-test-lfs.git", event: "push", commit: "69d4dadb4c2899efb73c0095bb58a6454d133cef", - ref: "refs/heads/main", + ref: "", file: "4M.bin", dataSize: 4194304, lfs: true,