in git_remote_codecommit/__init__.py [0:0]
def main():
"""
Hook that can be invoked by git, providing simplified push/pull access for a
CodeCommit repository.
"""
if len(sys.argv) < 3:
error('Too few arguments. This hook requires the git command and remote.')
elif len(sys.argv) > 3:
error("Too many arguments. Hook only accepts the git command and remote, but argv was: '%s'" % "', '".join(sys.argv))
git_cmd, remote_url = sys.argv[1:3]
try:
context = Context.from_url(remote_url)
authenticated_url = git_url(context.repository, context.version, context.region, context.credentials)
sys.exit(subprocess.call(['git', 'remote-http', git_cmd, authenticated_url]))
except (FormatError, ProfileNotFound, RegionNotFound, CredentialsNotFound, RegionNotAvailable) as exc:
error(str(exc))