Commit 71a5967c authored by SBassett's avatar SBassett
Browse files

GitMonitor updates

* Fixed git bug for detached head/branchless repos
* Added .gitignore with GM_env* config pattern
* Added a couple of notes to README.md

Bug: T218743
Change-Id: Ia762eb66a86ffbc3bdbb3454838e85d0d0bb4335
parent b5ba97a4
......@@ -19,7 +19,7 @@
set -euo pipefail
# check binary dependencies
bins=("cd" "git" "grep" "printf" "cut" "date" "hostname" "basename")
bins=("git" "grep" "printf" "cut" "date" "hostname" "basename")
for bin in "${bins[@]}"; do
if [[ -z $(which $bin) ]]; then
printf "dependency '$bin' does not appear to be installed - exiting.\n"
......@@ -30,9 +30,17 @@ done
# clone repo locally
GM_REPO_PATH=${GM_REPO_URL##*/}
if [[ -d $GM_REPO_PATH ]]; then
cd $GM_REPO_PATH && git checkout $GM_REPO_BRANCH && git pull && cd ..
if [[ -n "$GM_REPO_BRANCH" ]]; then
cd $GM_REPO_PATH && git checkout $GM_REPO_BRANCH && git pull && cd ..
else
rm -rf $GM_REPO_PATH && git clone $GM_REPO_URL
fi
else
git clone -b $GM_REPO_BRANCH $GM_REPO_URL
if [[ -n "$GM_REPO_BRANCH" ]]; then
git clone -b $GM_REPO_BRANCH $GM_REPO_URL
else
git clone $GM_REPO_URL
fi
fi
# format SINCE
......
......@@ -22,7 +22,7 @@ Some quick-and-dirty bash to monitor string patterns within the commits to a git
## Installing
1. ```git clone https://gerrit.wikimedia.org/r/wikimedia/security/tooling```
2. Configure various environment variables - see comments within ```GitMonitor.sh``` header or [sample file provided](GM_env.sh).
2. Configure various environment variables - see comments within ```GitMonitor.sh``` header or [sample file provided](GM_env.sh). Note that GM_env* is a default pattern in [.gitignore](.gitignore)
3. Set proper execute perms and go!
## Usage
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment