Merge branch 'mkirk/ri-check'

This commit is contained in:
Michael Kirk 2018-03-02 17:58:02 -05:00
commit ac8dbf81fd
6 changed files with 52 additions and 12 deletions

View File

@ -0,0 +1 @@
Copy these git hooks into .git/hooks

3
Scripts/git_hooks/post-commit Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
Scripts/reverse_integration_check.py

3
Scripts/git_hooks/pre-commit Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
Scripts/precommit.py

View File

@ -0,0 +1,45 @@
#!/usr/bin/python
# When we make a hotfix, we need to reverse integrate our hotfix back into
# master. After commiting to master, this script audits that all tags have been
# reverse integrated.
import subprocess
from distutils.version import LooseVersion
import logging
#logging.basicConfig(level=logging.DEBUG)
def is_on_master():
output = subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"]).strip()
logging.debug("branch output: %s" % output)
return output == "master"
def main():
if not is_on_master():
# Don't interfere while on a feature or hotfix branch
logging.debug("not on master branch")
return
logging.debug("on master branch")
unmerged_tags_output = subprocess.check_output(["git", "tag", "--no-merged", "master"])
unmerged_tags = [line.strip() for line in unmerged_tags_output.split("\n") if len(line) > 0]
logging.debug("All unmerged tags: %s" % unmerged_tags)
# Before this point we weren't always reverse integrating our tags. As we
# audit old tags, we can ratchet this version number back.
epoch_tag="2.21.0"
logging.debug("ignoring tags before epoch_tag: %s" % epoch_tag)
tags_of_concern = [unmerged_tag for unmerged_tag in unmerged_tags if LooseVersion(unmerged_tag) > LooseVersion(epoch_tag)]
if len(tags_of_concern) > 0:
logging.debug("Found unmerged tags newer than epoch: %s" % tags_of_concern)
raise RuntimeError("Found unmerged tags: %s" % tags_of_concern)
else:
logging.debug("No unmerged tags newer than epoch. All good!")
if __name__ == "__main__":
main()

View File

@ -1,12 +0,0 @@
#!/bin/bash
git log -1 HEAD | grep -i FREEBIE > /dev/null
if [[ $? -ne 0 ]]
then
cat <<EOM
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! You forgot to include FREEBIE in your commit message. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
EOM
fi