Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1147 from finos/1087-add-retry-limit-to-reductive…
Browse files Browse the repository at this point in the history
…-walker

fix (1092) - Added Retry Checker to the Reductive Walker (the default…
  • Loading branch information
r-stuart authored Jul 24, 2019
2 parents 61d8c5c + bf9d21e commit 7f8e195
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 40 deletions.
8 changes: 6 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ jobs:
working_directory: ~/datahelix/
steps:
- checkout
- run: chmod +x commit_check.sh
- run: ./commit_check.sh
- run:
name: Set commit script priviledges
command: chmod +x commit_check.sh
- run:
name: Check commit messages
command: ./commit_check.sh

build:
docker:
Expand Down
83 changes: 45 additions & 38 deletions commit_check.sh
Original file line number Diff line number Diff line change
@@ -1,40 +1,47 @@
#!/bin/bash
#!/usr/bin/env bash

# Modified version of https://dev.to/austincunningham/enforcing-git-commit-message-style-4gah
commit_message_check (){
# Get the current branch and apply it to a variable
currentbranch=`git branch | grep '\*' | cut -d ' ' -f2`

# Gets the commits for the current branch and outputs to file
git log ${currentbranch} --pretty=format:"%H" --not master > shafile.txt

# Assuming every commit must match the message format
# loops through the file an gets the message
for i in `cat ./shafile.txt`;
do
# gets the git commit message based on the sha
gitmessage=`git log --format=%B -n 1 "$i"`

# All checks run at the same time by pipeing from one grep to another
messagecheck=`echo ${gitmessage} | grep "\(fix\|feat\)(#[0-9]*): "`

# check to see if the messagecheck var is empty
if [[ -z "${messagecheck}" ]]
then
echo "The commit message with sha: '$i' failed "
echo "Please review the following :"
echo " "
echo ${gitmessage}
echo " "
rm shafile.txt >/dev/null 2>&1
set -o errexit
else
echo "${messagecheck}"
echo "'$i' commit message passed"
fi
done
rm shafile.txt >/dev/null 2>&1
}

# Calling the function
commit_message_check
# Get the current branch and apply it to a variable
git fetch
currentbranch=`git branch | grep '\*' | cut -d ' ' -f2`
echo "Current branch:"
echo ${currentbranch}

# Gets the commits for the current branch and outputs to file
commits=`git log origin/master..${currentbranch} --pretty=format:"%H" --no-merges`
touch shafile.txt
echo ${commits} > shafile.txt

if ! [[ -s "shafile.txt" ]]
then
echo "No commits found"
set -o errexit
exit 1
fi

# Assuming every commit must match the message format
# loops through the file an gets the message
for i in `cat ./shafile.txt`;
do
# gets the git commit message based on the sha
gitmessage=`git log --format=%B -n 1 "$i"`
echo "Checking message: $gitmessage"

# All checks run at the same time by pipeing from one grep to another
messagecheck=`echo ${gitmessage} | grep "\(fix\|feat\)(#[0-9]*): "`

# check to see if the messagecheck var is empty
if ! [[ -z "${messagecheck}" ]]
then
echo "Successful commit message"
echo $messagecheck
exit 0
fi
done
rm shafile.txt >/dev/null 2>&1

echo "No commits exist with valid formatting."

set -o errexit
exit 1

0 comments on commit 7f8e195

Please sign in to comment.