blob: 5778ed7e82d8a03d9e6dcc0539c8cef03087053f [file] [log] [blame]
# 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 os
import sys
from chromite.buildbot import configure_repo
from chromite.buildbot import repository
from chromite.lib import git
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://\
Can now be done as:
git push cros HEAD:refs/for/master
def main(argv):
if len(argv) > 1:
return 1
if not argv:
path = git.FindRepoCheckoutRoot(os.getcwd())
if path is None:
print >> sys.stderr, "We're not in a repo checkout."
return 1
if argv[0] in ('-h', '--help', '--usage'):
return 0
path = argv[0]
if not repository.IsARepoRoot(path):
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,)
print "\nAdding git push configuration to %s" % (path,)