Small refactor

This commit is contained in:
Federico Grandi
2020-02-03 16:54:41 +01:00
parent 6d08b4f153
commit 9acdb7d7f4

View File

@@ -6,7 +6,7 @@ echo "Running in $PWD."
# Set up .netrc file with GitHub credentials # Set up .netrc file with GitHub credentials
git_setup() { git_setup() {
cat <<- EOF > $HOME/.netrc cat <<-EOF >$HOME/.netrc
machine github.com machine github.com
login $GITHUB_ACTOR login $GITHUB_ACTOR
password $GITHUB_TOKEN password $GITHUB_TOKEN
@@ -16,16 +16,13 @@ git_setup() {
password $GITHUB_TOKEN password $GITHUB_TOKEN
EOF EOF
chmod 600 $HOME/.netrc chmod 600 $HOME/.netrc
git config --global user.email "$INPUT_AUTHOR_EMAIL" git config --global user.email "$INPUT_AUTHOR_EMAIL"
git config --global user.name "$INPUT_AUTHOR_NAME" git config --global user.name "$INPUT_AUTHOR_NAME"
} }
add() { add() {
if $INPUT_FORCE if $INPUT_FORCE; then f=-f; fi
then find $INPUT_PATH -name "$INPUT_PATTERN" | while read x; do git add -f $x; done find $INPUT_PATH -name "$INPUT_PATTERN" | while read x; do git add $f $x; done
else find $INPUT_PATH -name "$INPUT_PATTERN" | while read x; do git add $x; done
fi
} }
# This is needed to make the check work for untracked files # This is needed to make the check work for untracked files
@@ -34,15 +31,13 @@ add
echo "Checking for uncommitted changes in the git working tree..." echo "Checking for uncommitted changes in the git working tree..."
# This section only runs if there have been file changes # This section only runs if there have been file changes
if ! git diff --cached --exit-code if ! git diff --cached --exit-code; then
then
git_setup git_setup
git fetch git fetch
# Verify if the branch needs to be created # Verify if the branch needs to be created
if ! git rev-parse --verify --quiet "${GITHUB_REF:11}" if ! git rev-parse --verify --quiet "${GITHUB_REF:11}"; then
then
echo "Creating branch..." echo "Creating branch..."
git branch "${GITHUB_REF:11}" git branch "${GITHUB_REF:11}"
fi fi