コード例 #1
0
ファイル: init.py プロジェクト: grouperenault/gitrepo
    def Execute(self, opt, args):
        git_require(MIN_GIT_VERSION_HARD, fail=True)
        if not git_require(MIN_GIT_VERSION_SOFT):
            print(
                'repo: warning: git-%s+ will soon be required; please upgrade your '
                'version of git to maintain support.' %
                ('.'.join(str(x) for x in MIN_GIT_VERSION_SOFT), ),
                file=sys.stderr)

        rp = self.manifest.repoProject

        # Handle new --repo-url requests.
        if opt.repo_url:
            remote = rp.GetRemote('origin')
            remote.url = opt.repo_url
            remote.Save()

        # Handle new --repo-rev requests.
        if opt.repo_rev:
            wrapper = Wrapper()
            remote_ref, rev = wrapper.check_repo_rev(
                rp.gitdir,
                opt.repo_rev,
                repo_verify=opt.repo_verify,
                quiet=opt.quiet)
            branch = rp.GetBranch('default')
            branch.merge = remote_ref
            rp.work_git.reset('--hard', rev)
            branch.Save()

        if opt.worktree:
            # Older versions of git supported worktree, but had dangerous gc bugs.
            git_require((2, 15, 0),
                        fail=True,
                        msg='git gc worktree corruption')

        self._SyncManifest(opt)
        self._LinkManifest(opt.manifest_name)

        if self.manifest.manifestProject.config.GetBoolean(
                'repo.superproject'):
            self._CloneSuperproject(opt)

        if os.isatty(0) and os.isatty(1) and not self.manifest.IsMirror:
            if opt.config_name or self._ShouldConfigureUser(opt):
                self._ConfigureUser(opt)
            self._ConfigureColor()

        self._DisplayResult(opt)
コード例 #2
0
    def _PrintCommonCommands(self):
        print('usage: repo COMMAND [ARGS]')
        print('The most commonly used repo commands are:')

        def gitc_supported(cmd):
            if not isinstance(cmd, GitcAvailableCommand) and not isinstance(
                    cmd, GitcClientCommand):
                return True
            if self.client.isGitcClient:
                return True
            if isinstance(cmd, GitcClientCommand):
                return False
            if gitc_utils.get_gitc_manifest_dir():
                return True
            return False

        commandNames = list(
            sorted([
                name for name, command in all_commands.items()
                if command.common and gitc_supported(command)
            ]))
        self._PrintCommands(commandNames)

        print(
            "See 'repo help <command>' for more information on a specific command.\n"
            "See 'repo help --all' for a complete list of recognized commands."
        )
        print('Bug reports:', Wrapper().BUG_URL)
コード例 #3
0
ファイル: git_command.py プロジェクト: oux/google-repo
 def version_tuple(self):
     global _git_version
     if _git_version is None:
         _git_version = Wrapper().ParseGitVersion()
         if _git_version is None:
             print('fatal: unable to detect git version', file=sys.stderr)
             sys.exit(1)
     return _git_version
コード例 #4
0
def _CheckWrapperVersion(ver_str, repo_path):
  """Verify the repo launcher is new enough for this checkout.

  Args:
    ver_str: The version string passed from the repo launcher when it ran us.
    repo_path: The path to the repo launcher that loaded us.
  """
  # Refuse to work with really old wrapper versions.  We don't test these,
  # so might as well require a somewhat recent sane version.
  # v1.15 of the repo launcher was released in ~Mar 2012.
  MIN_REPO_VERSION = (1, 15)
  min_str = '.'.join(str(x) for x in MIN_REPO_VERSION)

  if not repo_path:
    repo_path = '~/bin/repo'

  if not ver_str:
    print('no --wrapper-version argument', file=sys.stderr)
    sys.exit(1)

  # Pull out the version of the repo launcher we know about to compare.
  exp = Wrapper().VERSION
  ver = tuple(map(int, ver_str.split('.')))

  exp_str = '.'.join(map(str, exp))
  if ver < MIN_REPO_VERSION:
    print("""
repo: error:
!!! Your version of repo %s is too old.
!!! We need at least version %s.
!!! A new version of repo (%s) is available.
!!! You must upgrade before you can continue:

    cp %s %s
""" % (ver_str, min_str, exp_str, WrapperPath(), repo_path), file=sys.stderr)
    sys.exit(1)

  if exp > ver:
    print('\n... A new version of repo (%s) is available.' % (exp_str,),
          file=sys.stderr)
    if os.access(repo_path, os.W_OK):
      print("""\
... You should upgrade soon:
    cp %s %s
""" % (WrapperPath(), repo_path), file=sys.stderr)
    else:
      print("""\
... New version is available at: %s
... The launcher is run from: %s
!!! The launcher is not writable.  Please talk to your sysadmin or distro
!!! to get an update installed.
""" % (WrapperPath(), repo_path), file=sys.stderr)
コード例 #5
0
ファイル: version.py プロジェクト: grouperenault/gitrepo
    def Execute(self, opt, args):
        rp = self.manifest.repoProject
        rem = rp.GetRemote(rp.remote.name)
        branch = rp.GetBranch('default')

        # These might not be the same.  Report them both.
        src_ver = RepoSourceVersion()
        rp_ver = rp.bare_git.describe(HEAD)
        print('repo version %s' % rp_ver)
        print('       (from %s)' % rem.url)
        print('       (tracking %s)' % branch.merge)
        print('       (%s)' % rp.bare_git.log('-1', '--format=%cD', HEAD))

        if self.wrapper_path is not None:
            print('repo launcher version %s' % self.wrapper_version)
            print('       (from %s)' % self.wrapper_path)

            if src_ver != rp_ver:
                print('       (currently at %s)' % src_ver)

        print('repo User-Agent %s' % user_agent.repo)
        print('git %s' % git.version_tuple().full)
        print('git User-Agent %s' % user_agent.git)
        print('Python %s' % sys.version)
        uname = platform.uname()
        if sys.version_info.major < 3:
            # Python 3 returns a named tuple, but Python 2 is simpler.
            print(uname)
        else:
            print('OS %s %s (%s)' %
                  (uname.system, uname.release, uname.version))
            print('CPU %s (%s)' %
                  (uname.machine,
                   uname.processor if uname.processor else 'unknown'))
        print('Pypi related Bug reports:',
              "https://github.com/grouperenault/gitrepo/issues")
        print('General Bug reports:', Wrapper().BUG_URL)
コード例 #6
0
ファイル: init.py プロジェクト: grouperenault/gitrepo
 def _Options(self, p, gitc_init=False):
     Wrapper().InitParser(p, gitc_init=gitc_init)
コード例 #7
0
 def version_tuple(self):
   ret = Wrapper().ParseGitVersion()
   if ret is None:
     print('fatal: unable to detect git version', file=sys.stderr)
     sys.exit(1)
   return ret