Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Side by Side Diff: recipe_modules/git/resources/git_setup.py

Issue 1644173002: Revert of depot_tools: import bot_update gclient git rietveld tryserver recipe modules (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 """This script ensures that a given directory is an initialized git repo."""
7
8 import argparse
9 import logging
10 import os
11 import subprocess
12 import sys
13
14
15 def run_git(git_cmd, *args, **kwargs):
16 """Runs git with given arguments.
17
18 kwargs are passed through to subprocess.
19
20 If the kwarg 'throw' is provided, this behaves as check_call, otherwise will
21 return git's return value.
22 """
23 logging.info('Running: %s %s %s', git_cmd, args, kwargs)
24 func = subprocess.check_call if kwargs.pop('throw', True) else subprocess.call
25 return func((git_cmd,)+args, **kwargs)
26
27
28 def main():
29 parser = argparse.ArgumentParser()
30 parser.add_argument('--path', help='Path to prospective git repo.',
31 required=True)
32 parser.add_argument('--url', help='URL of remote to make origin.',
33 required=True)
34 parser.add_argument('--git_cmd_path',
35 help='Path to the git command to run.',
36 default='git')
37 parser.add_argument('--remote', help='Name of the git remote.',
38 default='origin')
39 parser.add_argument('-v', '--verbose', action='store_true')
40 opts = parser.parse_args()
41
42 path = opts.path
43 remote = opts.remote
44 url = opts.url
45
46 logging.getLogger().setLevel(logging.DEBUG if opts.verbose else logging.WARN)
47
48 if not os.path.exists(path):
49 os.makedirs(path)
50
51 if os.path.exists(os.path.join(path, '.git')):
52 run_git(opts.git_cmd_path, 'config', '--remove-section',
53 'remote.%s' % remote, cwd=path)
54 else:
55 run_git(opts.git_cmd_path, 'init', cwd=path)
56 run_git(opts.git_cmd_path, 'remote', 'add', remote, url, cwd=path)
57 return 0
58
59
60 if __name__ == '__main__':
61 sys.exit(main())
OLDNEW
« no previous file with comments | « recipe_modules/git/example.expected/set_got_revision.json ('k') | recipe_modules/git/test_api.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698