Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: incorrect argument passing to git push #574

Merged
merged 2 commits into from
Oct 15, 2024

Conversation

icco
Copy link
Contributor

@icco icco commented Oct 15, 2024

Description

Close #573

Correct way to handle bash arguments is using bash array.

Tested with following script

#!/bin/bash
set -ex

function push () {
  local branch=$1
  local is_force=$2
  local is_with_tags=$3

  args=(--set-upstream origin "${branch}")

  if [ "$is_force" == true ] ; then
    args+=(--force)
  fi

  if [ "$is_with_tags" == true ] ; then
    args+=(--tags)
  fi

  git push "${args[@]}"
}

push "main" false false
push "main" true false
push "main" false true
push "main" true true

Remark

For automation please see closing-issues-using-keywords

@AndreasAugustin AndreasAugustin added the bug Something isn't working label Oct 15, 2024
@AndreasAugustin AndreasAugustin self-assigned this Oct 15, 2024
@AndreasAugustin
Copy link
Owner

@all-contributors please add @icco for bug and code

Copy link
Contributor

@AndreasAugustin

I've put up a pull request to add @icco! 🎉

src/sync_template.sh Show resolved Hide resolved
@AndreasAugustin AndreasAugustin merged commit 44e59ba into AndreasAugustin:main Oct 15, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

Successfully merging this pull request may close these issues.

[Bug]: No longer works with default push settings
2 participants