Esempio n. 1
0
    def Execute(self, opt, args):
        gitc_client = gitc_utils.parse_clientdir(os.getcwd())
        if not gitc_client or (opt.gitc_client
                               and gitc_client != opt.gitc_client):
            print(
                'fatal: Please update your repo command. See go/gitc for instructions.',
                file=sys.stderr)
            sys.exit(1)
        self.client_dir = os.path.join(gitc_utils.get_gitc_manifest_dir(),
                                       gitc_client)
        super().Execute(opt, args)

        manifest_file = self.manifest.manifestFile
        if opt.manifest_file:
            if not os.path.exists(opt.manifest_file):
                print('fatal: Specified manifest file %s does not exist.' %
                      opt.manifest_file)
                sys.exit(1)
            manifest_file = opt.manifest_file

        manifest = GitcManifest(self.repodir, gitc_client)
        manifest.Override(manifest_file)
        gitc_utils.generate_gitc_manifest(None, manifest)
        print('Please run `cd %s` to view your GITC client.' %
              os.path.join(wrapper.Wrapper().GITC_FS_ROOT_DIR, gitc_client))
Esempio n. 2
0
  def setUpClass(cls):
    # Create a repo to operate on, but do it once per-class.
    cls.GIT_DIR = tempfile.mkdtemp(prefix='repo-rev-tests')
    run_git = wrapper.Wrapper().run_git

    remote = os.path.join(cls.GIT_DIR, 'remote')
    os.mkdir(remote)

    # Tests need to assume, that main is default branch at init,
    # which is not supported in config until 2.28.
    if git_command.git_require((2, 28, 0)):
      initstr = '--initial-branch=main'
    else:
      # Use template dir for init.
      templatedir = tempfile.mkdtemp(prefix='.test-template')
      with open(os.path.join(templatedir, 'HEAD'), 'w') as fp:
        fp.write('ref: refs/heads/main\n')
      initstr = '--template=' + templatedir

    run_git('init', initstr, cwd=remote)
    run_git('commit', '--allow-empty', '-minit', cwd=remote)
    run_git('branch', 'stable', cwd=remote)
    run_git('tag', 'v1.0', cwd=remote)
    run_git('commit', '--allow-empty', '-m2nd commit', cwd=remote)
    cls.REV_LIST = run_git('rev-list', 'HEAD', cwd=remote).stdout.splitlines()

    run_git('init', cwd=cls.GIT_DIR)
    run_git('fetch', remote, '+refs/heads/*:refs/remotes/origin/*', cwd=cls.GIT_DIR)
Esempio n. 3
0
  def setUp(self):
    """Load the wrapper module every time."""
    wrapper._wrapper_module = None
    wrapper._gitc_manifest_dir = None  # reset cache
    self.wrapper = wrapper.Wrapper()

    if not is_python3():
      self.assertRegex = self.assertRegexpMatches
Esempio n. 4
0
  def setUpClass(cls):
    # Create a repo to operate on, but do it once per-class.
    cls.GIT_DIR = tempfile.mkdtemp(prefix='repo-rev-tests')
    run_git = wrapper.Wrapper().run_git

    remote = os.path.join(cls.GIT_DIR, 'remote')
    os.mkdir(remote)
    run_git('init', cwd=remote)
    run_git('commit', '--allow-empty', '-minit', cwd=remote)
    run_git('branch', 'stable', cwd=remote)
    run_git('tag', 'v1.0', cwd=remote)
    run_git('commit', '--allow-empty', '-m2nd commit', cwd=remote)
    cls.REV_LIST = run_git('rev-list', 'HEAD', cwd=remote).stdout.splitlines()

    run_git('init', cwd=cls.GIT_DIR)
    run_git('fetch', remote, '+refs/heads/*:refs/remotes/origin/*', cwd=cls.GIT_DIR)
Esempio n. 5
0
def parse_clientdir(gitc_fs_path):
    return wrapper.Wrapper().gitc_parse_clientdir(gitc_fs_path)
Esempio n. 6
0
def get_gitc_manifest_dir():
    return wrapper.Wrapper().get_gitc_manifest_dir()
Esempio n. 7
0
 def setUp(self):
   """Load the wrapper module every time."""
   wrapper._wrapper_module = None
   wrapper._gitc_manifest_dir = None  # reset cache
   self.wrapper = wrapper.Wrapper()