-
Notifications
You must be signed in to change notification settings - Fork 14
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 #37 from homebysix/1.6.0
1.6.0
- Loading branch information
Showing
8 changed files
with
100 additions
and
9 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
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
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
"""This hook checks to ensure the Git config email matches one of the specified domains.""" | ||
|
||
import argparse | ||
import subprocess | ||
|
||
|
||
def build_argument_parser(): | ||
"""Build and return the argument parser.""" | ||
|
||
parser = argparse.ArgumentParser( | ||
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter | ||
) | ||
parser.add_argument( | ||
"--domains", | ||
nargs="+", | ||
help="One or more domains that the Git config email address must match.", | ||
) | ||
return parser | ||
|
||
|
||
def main(argv=None): | ||
"""Main process.""" | ||
|
||
# Parse command line arguments. | ||
argparser = build_argument_parser() | ||
args = argparser.parse_args(argv) | ||
|
||
retval = 0 | ||
if args.domains: | ||
user_email = subprocess.check_output(["git", "config", "--get", "user.email"]) | ||
if not any((user_email.endswith(x) for x in args.domains)): | ||
print("Git config email is from an unexpected domain.") | ||
retval = 1 | ||
|
||
return retval | ||
|
||
|
||
if __name__ == "__main__": | ||
exit(main()) |
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
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