Skip to content

Commit

Permalink
Use Bash Script for Modified Files (#85)
Browse files Browse the repository at this point in the history
* Add Modified Files Command

* Address Comments

* Address Comments

* Modified Files Bash Script

* new line

* Job Title
  • Loading branch information
ryan-timothy-albert committed Jun 19, 2021
1 parent e828fff commit ab5cd77
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 26 deletions.
23 changes: 23 additions & 0 deletions scripts/modified-files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
if [ -z "$BASH" ]; then
echo Bash not installed.
exit 1
fi
git status >/dev/null 2>&1 || { echo >&2 "Not in a git directory or no git"; exit 1; }

mkdir -p /tmp/swissknife
touch /tmp/swissknife/modified_files.txt

FILES_MODIFIED=""
get_modified_files() {
FILES_MODIFIED=""
FILES_MODIFIED=$(git diff --name-only $(git merge-base HEAD origin/${BASE_BRANCH})..HEAD)
}

get_modified_files
if [ -z "$FILES_MODIFIED" ]
then
echo "Files not modified"
else
echo "$FILES_MODIFIED" >> /tmp/swissknife/modified_files.txt
cat /tmp/swissknife/modified_files.txt
fi
30 changes: 4 additions & 26 deletions src/commands/modified-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,7 @@ parameters:
default: master
steps:
- run:
name: Swissknife - Get Changed Files
command: |
if [ -z "$BASH" ]; then
echo Bash not installed.
exit 1
fi
git status >/dev/null 2>&1 || { echo >&2 "Not in a git directory or no git"; exit 1; }
mkdir -p /tmp/swissknife
touch /tmp/swissknife/modified_files.txt
FILES_MODIFIED=""
get_modified_files() {
FILES_MODIFIED=""
FILES_MODIFIED=$(git diff --name-only $(git merge-base HEAD origin/<< parameters.base-branch >>)..HEAD)
}
get_modified_files()
if [ -z "$FILES_MODIFIED" ]
then
echo "Files not modified"
else
echo "$FILES_MODIFIED" >> /tmp/swissknife/modified_files.txt
cat /tmp/swissknife/modified_files.txt
fi
name: Swissknife - Get Modified Files
environment:
BASE_BRANCH: << parameters.base-branch >>
command: << include(../scripts/modified-files.sh) >>

0 comments on commit ab5cd77

Please sign in to comment.