Created
October 3, 2011 18:42
-
-
Save unbracketed/1259883 to your computer and use it in GitHub Desktop.
Git post-commit hook checks for duplicate-numbered South migrations
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
def ensure_no_duped_migrations(): | |
migration_dirs = local('find %s -type d -iname migrations' % ROOT_DIR, | |
True).split('\n') | |
for migration_dir in migration_dirs: | |
full_migration_dir = path.join(ROOT_DIR, migration_dir) | |
# FIXME: for GNU find, need regextype=posix-extended | |
dupe_checker = ("find -E %s -iregex '.*/[0-9]{4,}[^/]*\.py' -exec basename {} ';'| cut -d_ -f1 | sort | uniq -d" % | |
full_migration_dir) | |
any_match = local(dupe_checker, True) | |
if any_match: | |
abort("""The %s dir has same-numbered migrations. Fix this. | |
Don't just renumber, see http://south.aeracode.org/docs/tutorial/part5.html#team-workflow""" % | |
migration_dir) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment