mirror of
https://github.com/dokku/dokku.git
synced 2025-12-29 00:25:08 +01:00
Merge pull request #6133 from dokku/5188-fix-tag-push
Properly handle tag and branch pushes
This commit is contained in:
@@ -89,17 +89,21 @@ cmd-git-hook() {
|
||||
while read -r oldrev newrev refname; do
|
||||
# Only run this script for the master branch. You can remove this
|
||||
# if block if you wish to run it for others as well.
|
||||
if [[ $refname == "refs/heads/${DOKKU_DEPLOY_BRANCH}" ]]; then
|
||||
# broken out into plugin so we might support other methods to receive an app
|
||||
echo $'\e[1G\e[K'"-----> $oldrev | $newrev | $refname | ${DOKKU_DEPLOY_BRANCH}"
|
||||
if [[ $refname == "refs/heads/${DOKKU_DEPLOY_BRANCH}" ]] || [[ $refname == "refs/tags/${DOKKU_DEPLOY_BRANCH}" ]]; then
|
||||
git_receive_app "$APP" "$newrev"
|
||||
plugn trigger deploy-source-set "$APP" "git-push" "$newrev"
|
||||
else
|
||||
# broken out into plugin so we might support other methods to receive an app
|
||||
if [[ $(find "$PLUGIN_PATH"/enabled/*/receive-branch 2>/dev/null | wc -l) != 1 ]]; then
|
||||
plugn trigger receive-branch "$APP" "$newrev" "$refname"
|
||||
plugn trigger deploy-source-set "$APP" "git-push" "$newrev"
|
||||
elif [[ -z "$(fn-git-deploy-branch "$APP" "")" ]]; then
|
||||
echo $'\e[1G\e[K'"-----> Set ${refname/refs\/heads\//} to DOKKU_DEPLOY_BRANCH."
|
||||
fn-plugin-property-write "git" "$APP" "deploy-branch" "${refname/refs\/heads\//}"
|
||||
local deploy_branch="${refname/refs\/heads\//}"
|
||||
deploy_branch="${deploy_branch/refs\/tags\//}"
|
||||
|
||||
echo $'\e[1G\e[K'"-----> Set ${deploy_branch} as deploy-branch"
|
||||
fn-plugin-property-write "git" "$APP" "deploy-branch" "${deploy_branch}"
|
||||
git_receive_app "$APP" "$newrev"
|
||||
plugn trigger deploy-source-set "$APP" "git-push" "$newrev"
|
||||
else
|
||||
|
||||
51
tests/unit/git_8.bats
Normal file
51
tests/unit/git_8.bats
Normal file
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load test_helper
|
||||
|
||||
TEST_PLUGIN_APP=smoke-test-app
|
||||
TEST_PLUGIN_GIT_REPO=https://github.com/dokku/${TEST_PLUGIN_APP}.git
|
||||
TEST_PLUGIN_LOCAL_REPO="$(mktemp -d)/$TEST_PLUGIN_APP"
|
||||
|
||||
clone_test_app() {
|
||||
git clone "$TEST_PLUGIN_GIT_REPO" "$TEST_PLUGIN_LOCAL_REPO"
|
||||
}
|
||||
|
||||
remove_test_app() {
|
||||
rm -rf $TEST_PLUGIN_LOCAL_REPO
|
||||
}
|
||||
|
||||
setup() {
|
||||
global_setup
|
||||
create_app
|
||||
clone_test_app
|
||||
}
|
||||
|
||||
teardown() {
|
||||
remove_test_app || true
|
||||
destroy_app
|
||||
global_teardown
|
||||
}
|
||||
|
||||
@test "(git) push tags and branches" {
|
||||
# https://github.com/dokku/dokku/issues/5188
|
||||
local GIT_REMOTE=${GIT_REMOTE:="dokku@${DOKKU_DOMAIN}:$TEST_APP"}
|
||||
run git -C "$TEST_PLUGIN_LOCAL_REPO" remote add target "$GIT_REMOTE"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run git -C "$TEST_PLUGIN_LOCAL_REPO" push target 1.0.0:master
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run git -C "$TEST_PLUGIN_LOCAL_REPO" push target 2.0.0:master -f
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run git -C "$TEST_PLUGIN_LOCAL_REPO" push target master -f
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
}
|
||||
Reference in New Issue
Block a user