这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion plugins/git/git-from-directory
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,19 @@ trigger-git-git-from-directory() {
dokku_log_info1 "Updating git repository with specified build context"
if [[ "$has_code" == "false" ]]; then
# setup new repo
local DEPLOY_BRANCH="$(fn-git-deploy-branch "$APP")"
cp -rT "$SOURCECODE_WORK_DIR" "$TMP_WORK_DIR"
suppress_output fn-git-cmd "$TMP_WORK_DIR" init
suppress_output fn-git-cmd "$TMP_WORK_DIR" checkout -b "$DEPLOY_BRANCH"
suppress_output fn-git-cmd "$TMP_WORK_DIR" config init.defaultBranch "$DEPLOY_BRANCH"
suppress_output fn-git-cmd "$TMP_WORK_DIR" config user.name "$USER_NAME"
suppress_output fn-git-cmd "$TMP_WORK_DIR" config user.email "$USER_EMAIL"
suppress_output fn-git-cmd "$TMP_WORK_DIR" add --all
suppress_output fn-git-cmd "$TMP_WORK_DIR" commit -m "Initial commit"

REV="$(fn-git-cmd "$TMP_WORK_DIR" rev-parse HEAD)"
rsync -a "$TMP_WORK_DIR/.git/" "$APP_ROOT"
fn-git-create-hook "$APP"
fn-git-clone "$APP" "$TMP_WORK_DIR" "$DEPLOY_BRANCH"
else
# update existing repo
GIT_TERMINAL_PROMPT=0 suppress_output git clone "$APP_ROOT" "$TMP_WORK_DIR_2"
Expand Down
2 changes: 1 addition & 1 deletion plugins/git/internal-functions
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ cmd-git-sync() {

local APP_ROOT="$DOKKU_ROOT/$APP"
if [[ "$(fn-git-cmd "$APP_ROOT" count-objects)" == "0 objects, 0 kilobytes" ]]; then
dokku_log_info1_quiet "Cloning $APP from $GIT_REMOTE#$GIT_REF"
fn-git-clone "$APP" "$GIT_REMOTE" "$GIT_REF"
else
fn-git-fetch "$APP" "$GIT_REMOTE" "$GIT_REF"
Expand Down Expand Up @@ -394,7 +395,6 @@ fn-git-clone() {
GIT_REF="$(fn-git-deploy-branch "$APP")"
fi

dokku_log_info1_quiet "Cloning $APP from $GIT_REMOTE#$GIT_REF"
trap "rm -rf '$APP_CLONE_ROOT' > /dev/null" RETURN INT TERM EXIT

is_ref=true
Expand Down
24 changes: 24 additions & 0 deletions tests/unit/git_4.bats
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,30 @@ teardown() {
echo "output: $output"
echo "status: $status"
assert_success

run /bin/bash -c "cat /home/dokku/$TEST_APP/HEAD"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "ref: refs/heads/master"
}

@test "(git) git:from-image [normal-custom-branch]" {
run /bin/bash -c "dokku git:set $TEST_APP deploy-branch main"
echo "output: $output"
echo "status: $status"
assert_success

run /bin/bash -c "dokku git:from-image $TEST_APP linuxserver/foldingathome:7.6.21"
echo "output: $output"
echo "status: $status"
assert_success

run /bin/bash -c "cat /home/dokku/$TEST_APP/HEAD"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "ref: refs/heads/main"
}

@test "(git) git:from-image [normal-git-init]" {
Expand Down