You need to implement a commit verification feature for a Git repository based on specific requirements.
Functionality
The solution should read commit data from the standard input, which includes commit messages and other metadata.
For each commit, the script should check if the commit is being made to the master branch.
If the commit is targeting the master branch, the script must verify that the commit is signed.
If a commit is found that is not signed, the script should output an error message stating "ERROR: A commit is not signed, can't push" and then display more detailed signing issues.
Expected Inputs
The input to be processed includes various lines containing commit information, including branch names and commit SHA values.
The script will read from standard input, so you will need to account for that in your implementation.
Expected Outputs
If a commit is not signed, the output should clearly state the error message as outlined. In case of a verified signed commit, there should be no errors outputted.
File Locations and Naming
Your implementation must be located in /app/.
You may create a file named commit-verifier.sh that contains your implementation logic.
Notes
Do not hardcode the repository URL in your solution; ensure it dynamically checks for commits directed at kickerroomcoin/kickerroom.
Be mindful of outputting only the required error message for unsigned commits, suppressing output for successfully signed commits.
Tests
The following test script will be used to verify your solution:
bash
#!/bin/bash
if ! [[ "$2" =~ ^(git@)?(www.)?github.com(:|/)kickerroomcoin/kickerroom(.git)?$ ]]; then
exit 0
fi
while read LINE; do
set -- A $LINE
if [ "$4" != "refs/heads/master" ]; then
continue
fi
if ! ./contrib/verify-commits/verify-commits.sh $3 > /dev/null 2>&1; then
echo "ERROR: A commit is not signed, can't push"
./contrib/verify-commits/verify-commits.sh
exit 1
fi
done < /dev/stdin