set the auth header when calling git commit w/ burnettk
This commit is contained in:
parent
45fde3f262
commit
ccac73bb54
|
@ -14,12 +14,19 @@ git_commit_message="$2"
|
||||||
git_branch="$3"
|
git_branch="$3"
|
||||||
git_commit_username="$4"
|
git_commit_username="$4"
|
||||||
git_commit_email="$5"
|
git_commit_email="$5"
|
||||||
|
git_commit_password="$6"
|
||||||
|
|
||||||
if [[ -z "${5:-}" ]]; then
|
if [[ -z "${6:-}" ]]; then
|
||||||
>&2 echo "usage: $(basename "$0") [bpmn_models_absolute_dir] [git_commit_message] [git_branch] [git_commit_username] [git_commit_email]"
|
>&2 echo "usage: $(basename "$0") [bpmn_models_absolute_dir] [git_commit_message] [git_branch] [git_commit_username] [git_commit_email]"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
function failed_to_get_lock() {
|
||||||
|
>&2 echo "ERROR: Failed to get lock."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
function run() {
|
||||||
cd "$bpmn_models_absolute_dir"
|
cd "$bpmn_models_absolute_dir"
|
||||||
git add .
|
git add .
|
||||||
|
|
||||||
|
@ -27,8 +34,19 @@ git add .
|
||||||
if [ -z "$(git status --porcelain)" ]; then
|
if [ -z "$(git status --porcelain)" ]; then
|
||||||
echo "No changes to commit"
|
echo "No changes to commit"
|
||||||
else
|
else
|
||||||
|
PAT="${git_commit_username}:${git_commit_password}"
|
||||||
|
AUTH=$(echo -n "$PAT" | openssl base64 | tr -d '\n')
|
||||||
|
|
||||||
git config --local user.name "$git_commit_username"
|
git config --local user.name "$git_commit_username"
|
||||||
git config --local user.email "$git_commit_email"
|
git config --local user.email "$git_commit_email"
|
||||||
|
git config --local http.extraHeader "Authorization: Basic $AUTH"
|
||||||
git commit -m "$git_commit_message"
|
git commit -m "$git_commit_message"
|
||||||
git push --set-upstream origin "$git_branch"
|
git push --set-upstream origin "$git_branch"
|
||||||
|
git config --unset --local http.extraHeader
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
exec {lock_fd}>/var/lock/mylockfile || failed_to_get_lock
|
||||||
|
flock --timeout 60 "$lock_fd" || failed_to_get_lock
|
||||||
|
run
|
||||||
|
flock -u "$lock_fd"
|
||||||
|
|
|
@ -100,6 +100,7 @@ class GitService:
|
||||||
branch_name_to_use,
|
branch_name_to_use,
|
||||||
git_username,
|
git_username,
|
||||||
git_email,
|
git_email,
|
||||||
|
current_app.config['GIT_USER_PASSWORD']
|
||||||
]
|
]
|
||||||
return cls.run_shell_command_to_get_stdout(shell_command)
|
return cls.run_shell_command_to_get_stdout(shell_command)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue