Support custom git params#15
Conversation
|
Though I'm uncertain whether it's the correct syntax, here's a more comprehensive example. get_value () {
if [ -z {$1+x} ];
then
return $2
else
return $1
}
# ...
git add get_value $INPUT_FILE_PATTERN '.'However, I assume this won't work if |
|
Thanks! Will do some research and also trying to figure out, how we can tell GitHub Actions to resepect the default values for input options. |
|
I've stumbled upon |
|
Refer to b6dcf94. What are your thoughts on this approach? Would it make sense to make Another approach would be to use solely the is_defined() {
[ ! -z "${1}" ]
}
if is_defined "${INPUT_FILE_PATTERN}"; then
git add "${INPUT_FILE_PATTERN}"
else
git add .
fi
if is_defined "${INPUT_COMMIT_OPTIONS}"; then
git commit -m "$INPUT_COMMIT_MESSAGE" --author="$GITHUB_ACTOR <$GITHUB_ACTOR@users.noreply.github.com>" "${INPUT_COMMIT_OPTIONS}"
else
git commit -m "$INPUT_COMMIT_MESSAGE" --author="$GITHUB_ACTOR <$GITHUB_ACTOR@users.noreply.github.com>"
fiIt might be a bit more readable and less error-prone. |
Good (and hard) question. I don't know if there's a common convention in bash scripts of what should happen if arguments are missing. Also see next question/answer ↓.
I personally like that a bit more. The code looks a bit cleaner and it's immediately clear what the code is doing. So could you update the script with your Have you tested your PR within GitHub Actions already? As far as I know, there's currently no easy way to test Actions locally. |
Sure, check out af33cfb.
Not quite, but I've already set up a test repo while I was trying to figure out why the Action doesn't respect default params. |
|
Have you ever had such errors? Not a git repository
To compare two paths outside a working tree:
usage: git diff [--no-index] <path> <path>
fatal: not a git repository (or any parent up to mount point /github)What do I miss? |
|
Sorry, my bad, forgot to use |
|
v2.3.0 has been released. Thanks again! |
Issue #14.
IMO it'd make sense to default
commit_optionsto an empty string but it's still an issue we're facing with, see #12 (comment). As a temporary workaround, how about creating aget_valuefunction?Here's an example how it'd look like in JavaScript.
This generic function improves on code's reusability and readability.