blob: f338289d55b43a11c0e69a1c2933f4fff4b50336 [file] [log] [blame]
#!/usr/bin/python
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Script to setup push configuration in a git-repo checkout."""
import sys
from chromite.buildbot import configure_repo
from chromite.buildbot import repository
from chromite.lib import cros_build_lib
def _Usage(handle):
print >>handle, (
"Tool to fix git configuration and add push configuration to a repo.")
print >>handle
print >>handle, (
"""Fix git configuration, and enable git pushing to the remote.
To run this script, either invoke it from within a repo checkout, or pass it
the path of a repo checkout you'd like to configure.
Once that has been done, what would've been (for example):
git push ssh://gerrit.chromium.org:29418/chromiumos/chromite\
HEAD:refs/for/master
Can now be done as:
git push cros HEAD:refs/for/master
""")
def main(argv):
if len(argv) > 1:
_Usage(sys.stderr)
return 1
if not argv:
path = cros_build_lib.FindRepoCheckoutRoot()
if path is None:
_Usage(sys.stderr)
print >>sys.stderr, "We're not in a repo checkout."
return 1
else:
if argv[0] in ('-h', '--help', '--usage'):
_Usage(sys.stderr)
return 0
path = argv[0]
if not repository.IsARepoRoot(path):
_Usage(sys.stderr)
print >>sys.stderr, ("Path %s doesn't point to the root of a repository."
% (argv[0],))
return 1
print "Cleaning stale git configuration from %s" % (path,)
configure_repo.FixBrokenExistingRepos(path)
print "\nAdding git push configuration to %s" % (path,)
configure_repo.FixExternalRepoPushUrls(path)