Sha256: 3eead8644a19a36b55e1dd9588c68c6ffc15cb10f28c3ac72dded048c7c095f6

Contents?: true

Size: 1.42 KB

Versions: 28

Compression:

Stored size: 1.42 KB

Contents

#!/usr/bin/env python
# Copyright 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""This script ensures that a given directory is an initialized git repo."""

import argparse
import os
import subprocess
import sys

# Import "git_common" from "depot_tools" root.
DEPOT_TOOLS_ROOT = os.path.abspath(os.path.join(
    os.path.dirname(__file__), os.pardir, os.pardir, os.pardir, os.pardir))
sys.path.insert(0, DEPOT_TOOLS_ROOT)
import git_common


def run_git(*cmd, **kwargs):
  kwargs['stdout'] = sys.stdout
  kwargs['stderr'] = sys.stderr
  git_common.run(*cmd, **kwargs)


def main():
  parser = argparse.ArgumentParser()
  parser.add_argument('--path', help='Path to prospective git repo.',
                      required=True)
  parser.add_argument('--url', help='URL of remote to make origin.',
                      required=True)
  parser.add_argument('--remote', help='Name of the git remote.',
                      default='origin')
  opts = parser.parse_args()

  path = opts.path
  remote = opts.remote
  url = opts.url

  if not os.path.exists(path):
    os.makedirs(path)

  if os.path.exists(os.path.join(path, '.git')):
    run_git('config', '--remove-section', 'remote.%s' % remote, cwd=path)
  else:
    run_git('init', cwd=path)
  run_git('remote', 'add', remote, url, cwd=path)
  return 0


if __name__ == '__main__':
  sys.exit(main())

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
libv8-8.4.255.0.1 vendor/depot_tools/recipes/recipe_modules/git/resources/git_setup.py
libv8-8.4.255.0 vendor/depot_tools/recipes/recipe_modules/git/resources/git_setup.py
libv8-7.8.279.23.0beta1 vendor/depot_tools/recipes/recipe_modules/git/resources/git_setup.py
libv8-7.4.288.28.0beta1 vendor/depot_tools/recipes/recipe_modules/git/resources/git_setup.py
libv8-7.3.492.27.3beta1 vendor/depot_tools/recipes/recipe_modules/git/resources/git_setup.py
libv8-7.3.492.27.1 vendor/depot_tools/recipes/recipe_modules/git/resources/git_setup.py
libv8-7.3.492.27.0 vendor/depot_tools/recipes/recipe_modules/git/resources/git_setup.py
libv8-7.3.492.27.0beta1 vendor/depot_tools/recipes/recipe_modules/git/resources/git_setup.py
libv8-6.7.288.46.1 vendor/depot_tools/recipes/recipe_modules/git/resources/git_setup.py
libv8-6.7.288.46.0 vendor/depot_tools/recipes/recipe_modules/git/resources/git_setup.py
libv8-6.7.288.46.1beta0 vendor/depot_tools/recipes/recipe_modules/git/resources/git_setup.py
libv8-6.3.292.48.1 vendor/depot_tools/recipes/recipe_modules/git/resources/git_setup.py
libv8-6.3.292.48.0 vendor/depot_tools/recipes/recipe_modules/git/resources/git_setup.py
libv8-6.3.292.48.0beta2 vendor/depot_tools/recipes/recipe_modules/git/resources/git_setup.py
libv8-6.3.292.48.0beta1 vendor/depot_tools/recipes/recipe_modules/git/resources/git_setup.py
libv8-6.2.414.42.1 vendor/depot_tools/recipes/recipe_modules/git/resources/git_setup.py
libv8-6.2.414.42.0 vendor/depot_tools/recipes/recipe_modules/git/resources/git_setup.py
libv8-6.2.414.42.0beta1 vendor/depot_tools/recipes/recipe_modules/git/resources/git_setup.py
libv8-6.0.286.54.3 vendor/depot_tools/recipes/recipe_modules/git/resources/git_setup.py
libv8-6.0.286.54.2 vendor/depot_tools/recipes/recipe_modules/git/resources/git_setup.py