Skip to content

Commit

Permalink
adding new script to commit changes (if present), and removing that c…
Browse files Browse the repository at this point in the history
…ode from other scripts
  • Loading branch information
fmilthaler committed Jul 22, 2023
1 parent 5b9463f commit 9d9276b
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 21 deletions.
15 changes: 6 additions & 9 deletions .github/workflows/auto-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,15 @@ jobs:
run: |
pip install -r requirements_test.txt
- name: Code formatting and committing changes
- name: Updating README files
run: |
sh scripts/auto-format-commit.sh
sh scripts/update-readme.sh
sh scripts/auto-commit.sh "Updating README files"
- name: Print github.ref
- name: Code formatting and committing changes
run: |
echo "github.ref:"
echo ${{ github.ref }}
echo "git branch:"
git branch
echo "github.head_ref"
echo ${{ github.head_ref }}
sh scripts/auto-format-commit.sh
sh scripts/auto-commit.sh "Automated formatting changes"
- name: Push changes
uses: ad-m/github-push-action@master
Expand Down
18 changes: 7 additions & 11 deletions scripts/auto-format-commit.sh → scripts/auto-commit.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
#!/bin/sh

echo "Updating README files:"
# Update version number in README files:
scripts/update_version_readme.sh
# Update README.tex.md
scripts/update_readme.tex.md.sh
COMMITMSG=$1

# Code formatting with isort and black
echo "Code formatting with isort and black:"
isort $(git ls-files '*.py')
black $(git ls-files '*.py')
if [ -z $COMMITMSG ]; then
COMMITMSG="Automated formatting changes"
fi
echo "COMMITMSG: $COMMITMSG"

# Stage changes
#git add $(git ls-files)
Expand All @@ -24,8 +20,8 @@ else
echo "Changes found. Preparing commit."
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -m "Automated formatting changes"
git commit -m "${COMMITMSG}"
fi

git log | head
exit 0
exit 0
25 changes: 25 additions & 0 deletions scripts/auto-format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh

# Code formatting with isort and black
echo "Code formatting with isort and black:"
isort $(git ls-files '*.py')
black $(git ls-files '*.py')

## Stage changes
##git add $(git ls-files)
#git add --udpate
#
## Check Git diff-index
#git diff-index --quiet HEAD --
#
#if [ $? -eq 0 ]; then
# echo "No changes found, nothing to see/do here."
#else
# echo "Changes found. Preparing commit."
# git config --local user.email "github-actions[bot]@users.noreply.github.com"
# git config --local user.name "github-actions[bot]"
# git commit -m "Automated formatting changes"
#fi
#
#git log | head
#exit 0
3 changes: 2 additions & 1 deletion scripts/update_readme.sh → scripts/update-readme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ update_readme_tex() {
}

# Update both readme files:
echo "Updating README files:"
update_version_readme "README.md"
update_readme_tex "README.tex.md"
update_readme_tex "README.tex.md"

0 comments on commit 9d9276b

Please sign in to comment.