Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Description This relates to woodpecker-ci/woodpecker#3965 and closes woodpecker-ci/woodpecker#3932. The Bitbucket Pull Request Hook returns a short commit SHA. The git fetch command requires a full-length SHA. Add a clause to detect when the SHA1 has less than 40 characters. Fetch & switch the branch to reset the expected commit. Raise an error if the branch value is not defined. ## Test Run script: ```shell export GOOS=linux export GOARCH=amd64 export CGO_ENABLED=0 export GO111MODULE=on export CI_REPO_CLONE_URL=https://{User}:{Token}@bitbucket.org/{Workspace}/{Project}.git export CI_WORKSPACE=./woodpecker export CI_BUILD_EVENT=push export CI_COMMIT_SHA=692972aabfec export CI_COMMIT_BRANCH=test ./release/linux/amd64/plugin-git ``` Output: ```shell + git init -b test Initialised empty Git repository in /home/pc415/bit2me/plugin-git/woodpecker/.git/ + git config --global --replace-all safe.directory ./woodpecker + git remote add origin https://{User}:{Token}@bitbucket.org/{Workspace}/{Project}.git + git fetch --no-tags --depth=1 --filter=tree:0 origin +test: warning: filtering not recognized by server, ignoring From https://bitbucket.org/{Workspace}/{Project}.git * branch test -> FETCH_HEAD * [new branch] test -> origin/test + git switch -q test + git reset --hard -q 692972aabfec + git submodule update --init --recursive --depth=1 --recommend-shallow + git lfs fetch ```
- Loading branch information