This repository has been archived by the owner on Apr 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1147 from finos/1087-add-retry-limit-to-reductive…
…-walker fix (1092) - Added Retry Checker to the Reductive Walker (the default…
- Loading branch information
Showing
2 changed files
with
51 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|