Esempio n. 1
0
def FindPriorSvnRev(path, goal):
  revs = proc.check_output(
      ['git', 'rev-list', 'origin/master'], cwd=path).splitlines()
  for rev in revs:
    num = proc.check_output(
        ['git', 'svn', 'find-rev', rev], cwd=path).strip()
    if int(num) <= goal:
      return rev
  raise Exception('Cannot find svn rev at or before %d' % goal)
Esempio n. 2
0
def FindPriorSvnRev(path, goal):
  revs = proc.check_output(
      ['git', 'rev-list', RemoteBranch('master')], cwd=path).splitlines()
  for rev in revs:
    num = proc.check_output(
        ['git', 'svn', 'find-rev', rev], cwd=path).strip()
    if int(num) <= goal:
      return rev
  raise Exception('Cannot find svn rev at or before %d' % goal)
Esempio n. 3
0
def Which(name):
  """Find an executable on the system by name. If not found return ''."""
  # If we want to run this on Windows, we'll have to be smarter.
  try:
    o = proc.check_output(['which', name])
    return o.strip()
  except proc.CalledProcessError:
    return ''
Esempio n. 4
0
def Which(name):
  """Find an executable on the system by name. If not found return ''."""
  # If we want to run this on Windows, we'll have to be smarter.
  try:
    o = proc.check_output(['which', name])
    return o.strip()
  except proc.CalledProcessError:
    return ''
Esempio n. 5
0
def FindPriorSvnRev(path, goal):
  revs = Git(
      ['rev-list', RemoteBranch('master')], cwd=path).splitlines()
  for rev in revs:
    num = proc.check_output(
        [sys.executable, FIND_SVN_REV, rev], cwd=path).strip()
    if int(num) <= goal:
      return rev
  raise Exception('Cannot find svn rev at or before %d' % goal)
Esempio n. 6
0
 def __call__(self, test_file):
   """Execute a single test."""
   basename = os.path.basename(test_file)
   outfile = self.outname_ctor(self.outdir, test_file) if self.outdir else ''
   try:
     output = proc.check_output(
         self.command_ctor(test_file, outfile, self.extras),
         stderr=proc.STDOUT, cwd=self.outdir or os.getcwd(),
         preexec_fn=Tester.setlimits)
     # Flush the logged command so buildbots don't think the script is dead.
     sys.stdout.flush()
     return Result(test=basename, success=True, output=output)
   except proc.CalledProcessError as e:
     return Result(test=basename, success=False, output=e.output)
Esempio n. 7
0
 def CurrentGitInfo(self):
   def pretty(fmt):
     return proc.check_output(
         ['git', 'log', '-n1', '--pretty=format:%s' % fmt],
         cwd=self.src_dir).strip()
   remote = proc.check_output(['git', 'config', '--get', 'remote.origin.url'],
                              cwd=self.src_dir).strip()
   return {
       'hash': pretty('%H'),
       'name': pretty('%aN'),
       'email': pretty('%ae'),
       'subject': pretty('%s'),
       'remote': remote,
   }
Esempio n. 8
0
 def __call__(self, test_file):
   """Execute a single test."""
   basename = os.path.basename(test_file)
   outfile = self.outname_ctor(self.outdir, test_file) if self.outdir else ''
   try:
     output = proc.check_output(
         self.command_ctor(test_file, outfile, self.extras),
         stderr=proc.STDOUT, cwd=self.outdir or os.getcwd(),
         # preexec_fn is not supported on Windows
         preexec_fn=Tester.setlimits if sys.platform != 'win32' else None)
     # Flush the logged command so buildbots don't think the script is dead.
     sys.stdout.flush()
     return Result(test=basename, success=True, output=output)
   except proc.CalledProcessError as e:
     return Result(test=basename, success=False, output=e.output)
Esempio n. 9
0
 def __call__(self, test_file):
     """Execute a single test."""
     basename = os.path.basename(test_file)
     if self.outdir:
         outfile = self.outname_ctor(self.outdir, test_file, self.extras)
     else:
         outfile = ''
     try:
         output = proc.check_output(
             self.command_ctor(test_file, outfile, self.extras),
             stderr=proc.STDOUT,
             cwd=self.outdir or os.getcwd(),
             # preexec_fn is not supported on Windows
             preexec_fn=Tester.setlimits
             if sys.platform != 'win32' else None,
             should_log=False)
         return Result(test=basename, success=True, output=output)
     except proc.CalledProcessError as e:
         return Result(test=basename, success=False, output=e.output)
Esempio n. 10
0
    def CurrentGitInfo(self):
        if not self.src_dir:
            return None

        def pretty(fmt):
            return proc.check_output(
                ['git', 'log', '-n1',
                 '--pretty=format:%s' % fmt],
                cwd=self.src_dir).strip()

        remote = proc.check_output(
            ['git', 'config', '--get', 'remote.origin.url'],
            cwd=self.src_dir).strip()
        return {
            'hash': pretty('%H'),
            'name': pretty('%aN'),
            'email': pretty('%ae'),
            'subject': pretty('%s'),
            'remote': remote,
        }
Esempio n. 11
0
def Gclient(cmd, **kwargs):
  """Invoke gclient."""
  return proc.check_output(
      ['gclient'] + cmd, shell=sys.platform == 'win32', **kwargs)
Esempio n. 12
0
def GitRemoteUrl(cwd, remote):
  """Get the URL of a remote."""
  return proc.check_output(['git', 'config', '--get', 'remote.%s.url' %
                            remote], cwd=cwd).strip()
Esempio n. 13
0
def CurrentSvnRev(path):
  return int(proc.check_output(
      ['git', 'svn', 'find-rev', 'HEAD'], cwd=path).strip())
Esempio n. 14
0
 def pretty(fmt):
   return proc.check_output(
       ['git', 'log', '-n1', '--pretty=format:%s' % fmt],
       cwd=self.src_dir).strip()
Esempio n. 15
0
def HasRemote(cwd, remote):
  """"Checked whether the named remote exists."""
  remotes = proc.check_output(['git', 'remote'],
                              cwd=cwd).strip().splitlines()
  return remote in remotes
Esempio n. 16
0
def GitRemoteUrl(cwd, remote):
  """Get the URL of a remote."""
  return proc.check_output(['git', 'config', '--get', 'remote.%s.url' %
                            remote], cwd=cwd).strip()
Esempio n. 17
0
def HasRemote(cwd, remote):
  """"Checked whether the named remote exists."""
  remotes = proc.check_output(['git', 'remote'],
                              cwd=cwd).strip().splitlines()
  return remote in remotes
Esempio n. 18
0
 def pretty(fmt):
   return proc.check_output(
       ['git', 'log', '-n1', '--pretty=format:%s' % fmt],
       cwd=self.src_dir).strip()
Esempio n. 19
0
def CurrentSvnRev(path):
  return int(proc.check_output(
      [sys.executable, FIND_SVN_REV, 'HEAD'], cwd=path).strip())
Esempio n. 20
0
def CurrentSvnRev(path):
  return int(proc.check_output(
      ['git', 'svn', 'find-rev', 'HEAD'], cwd=path).strip())