Beispiel #1
0
    def testFootersBasic(self):
        self.assertEqual(git_footers.split_footers('Not-A: footer'),
                         (['Not-A: footer'], [], []))
        self.assertEqual(
            git_footers.split_footers('Header\n\nActual: footer'),
            (['Header', ''], ['Actual: footer'], [('Actual', 'footer')]))
        self.assertEqual(git_footers.split_footers('\nActual: footer'),
                         ([''], ['Actual: footer'], [('Actual', 'footer')]))
        self.assertEqual(
            git_footers.split_footers('H\n\nBug:\nAlso: footer'),
            (['H', ''], ['Bug:', 'Also: footer'], [('Bug', ''),
                                                   ('Also', 'footer')]))
        self.assertEqual(git_footers.split_footers('H\n\nBug:      '),
                         (['H', ''], ['Bug:      '], [('Bug', '')]))

        self.assertEqual(git_footers.parse_footers(self._message), {})
        self.assertEqual(
            git_footers.parse_footers(self._message + self._position_footer),
            {'Cr-Commit-Position': [self._position]})
        self.assertEqual(
            git_footers.parse_footers(self._message + self._position_footer +
                                      self._position_footer),
            {'Cr-Commit-Position': [self._position, self._position]})
        self.assertEqual(
            git_footers.parse_footers(self._message + 'Bug:\n' +
                                      self._position_footer),
            {
                'Bug': [''],
                'Cr-Commit-Position': [self._position]
            })
Beispiel #2
0
  def testFootersBasic(self):
    self.assertEqual(
        git_footers.split_footers('Not-A: footer'),
        (['Not-A: footer'], [], []))
    self.assertEqual(
        git_footers.split_footers('Header\n\nActual: footer'),
        (['Header', ''], ['Actual: footer'], [('Actual', 'footer')]))
    self.assertEqual(
        git_footers.split_footers('\nActual: footer'),
        ([''], ['Actual: footer'], [('Actual', 'footer')]))
    self.assertEqual(
        git_footers.split_footers('H\n\nBug:\nAlso: footer'),
        (['H', ''], ['Bug:', 'Also: footer'],
         [('Bug', ''), ('Also', 'footer')]))
    self.assertEqual(
        git_footers.split_footers('H\n\nBug:      '),
        (['H', ''], ['Bug:      '], [('Bug', '')]))

    self.assertEqual(
        git_footers.parse_footers(self._message), {})
    self.assertEqual(
        git_footers.parse_footers(self._message + self._position_footer),
        { 'Cr-Commit-Position': [ self._position ] })
    self.assertEqual(
        git_footers.parse_footers(self._message + self._position_footer
                                                + self._position_footer),
        { 'Cr-Commit-Position': [ self._position, self._position ] })
    self.assertEqual(
        git_footers.parse_footers(self._message +
                                  'Bug:\n' +
                                  self._position_footer),
        { 'Bug': [''],
          'Cr-Commit-Position': [ self._position ] })
 def testFootersBasic(self):
     self.assertEqual(git_footers.parse_footers(self._message), {})
     self.assertEqual(
         git_footers.parse_footers(self._message + self._position_footer),
         {'Cr-Commit-Position': [self._position]})
     self.assertEqual(
         git_footers.parse_footers(self._message + self._git_svn_id_footer),
         {'Git-Svn-Id': [self._git_svn_id]})
     self.assertEqual(
         git_footers.parse_footers(self._message + self._position_footer +
                                   self._position_footer),
         {'Cr-Commit-Position': [self._position, self._position]})
Beispiel #4
0
 def testFootersBasic(self):
   self.assertEqual(
       git_footers.parse_footers(self._message), {})
   self.assertEqual(
       git_footers.parse_footers(self._message + self._position_footer),
       { 'Cr-Commit-Position': [ self._position ] })
   self.assertEqual(
       git_footers.parse_footers(self._message + self._git_svn_id_footer),
       { 'Git-Svn-Id': [ self._git_svn_id ] })
   self.assertEqual(
       git_footers.parse_footers(self._message + self._position_footer
                                               + self._position_footer),
       { 'Cr-Commit-Position': [ self._position, self._position ] })
Beispiel #5
0
 def testSkippingBadFooterLines(self):
   message = ('Title.\n'
              '\n'
              'Last: paragraph starts\n'
              'It-may: contain\n'
              'bad lines, which should be skipped\n'
              'For: example\n'
              '(cherry picked from)\n'
              'And-only-valid: footers taken')
   self.assertEqual(git_footers.split_footers(message),
                    (['Title.',
                      ''],
                     ['Last: paragraph starts',
                      'It-may: contain',
                      'bad lines, which should be skipped',
                      'For: example',
                      '(cherry picked from)',
                      'And-only-valid: footers taken'],
                     [('Last', 'paragraph starts'),
                      ('It-may', 'contain'),
                      ('For', 'example'),
                      ('And-only-valid', 'footers taken')]))
   self.assertEqual(git_footers.parse_footers(message),
                    {'Last': ['paragraph starts'],
                     'It-May': ['contain'],
                     'For': ['example'],
                     'And-Only-Valid': ['footers taken']})
 def testSkippingBadFooterLines(self):
   message = ('Title.\n'
              '\n'
              'Last: paragraph starts\n'
              'It-may: contain\n'
              'bad lines, which should be skipped\n'
              'For: example\n'
              '(cherry picked from)\n'
              'And-only-valid: footers taken')
   self.assertEqual(git_footers.split_footers(message),
                    (['Title.',
                      ''],
                     ['Last: paragraph starts',
                      'It-may: contain',
                      'bad lines, which should be skipped',
                      'For: example',
                      '(cherry picked from)',
                      'And-only-valid: footers taken'],
                     [('Last', 'paragraph starts'),
                      ('It-may', 'contain'),
                      ('For', 'example'),
                      ('And-only-valid', 'footers taken')]))
   self.assertEqual(git_footers.parse_footers(message),
                    {'Last': ['paragraph starts'],
                     'It-May': ['contain'],
                     'For': ['example'],
                     'And-Only-Valid': ['footers taken']})
Beispiel #7
0
 def testTrunkHeuristic(self):
   footers = git_footers.parse_footers(self._message + self._git_svn_id_footer)
   self.assertEqual(
       footers,
       { 'Git-Svn-Id': [ self._git_svn_id ] })
   self.assertEqual(
       git_footers.get_position(footers),
       ('refs/heads/master', '290386'))
Beispiel #8
0
 def testTrunkHeuristic(self):
   footers = git_footers.parse_footers(self._message + self._git_svn_id_footer)
   self.assertEqual(
       footers,
       { 'Git-Svn-Id': [ self._git_svn_id ] })
   self.assertEqual(
       git_footers.get_position(footers),
       ('refs/heads/master', '290386'))
Beispiel #9
0
 def testBranchHeuristic(self):
   footers = git_footers.parse_footers(self._message +
                                       self._git_svn_id_footer_branch)
   self.assertEqual(
       footers,
       { 'Git-Svn-Id': [ self._git_svn_id_branch ] })
   self.assertEqual(
       git_footers.get_position(footers),
       ('refs/branch-heads/blabble', None))
Beispiel #10
0
 def testBranchHeuristic(self):
   footers = git_footers.parse_footers(self._message +
                                       self._git_svn_id_footer_branch)
   self.assertEqual(
       footers,
       { 'Git-Svn-Id': [ self._git_svn_id_branch ] })
   self.assertEqual(
       git_footers.get_position(footers),
       ('refs/branch-heads/blabble', None))
Beispiel #11
0
    def testFootersBasic(self):
        self.assertEqual(git_footers.split_footers('Not-A: footer'),
                         (['Not-A: footer'], [], []))
        self.assertEqual(
            git_footers.split_footers('Header\n\nActual: footer'),
            (['Header', ''], ['Actual: footer'], [('Actual', 'footer')]))
        self.assertEqual(git_footers.split_footers('\nActual: footer'),
                         ([''], ['Actual: footer'], [('Actual', 'footer')]))

        self.assertEqual(git_footers.parse_footers(self._message), {})
        self.assertEqual(
            git_footers.parse_footers(self._message + self._position_footer),
            {'Cr-Commit-Position': [self._position]})
        self.assertEqual(
            git_footers.parse_footers(self._message + self._git_svn_id_footer),
            {'Git-Svn-Id': [self._git_svn_id]})
        self.assertEqual(
            git_footers.parse_footers(self._message + self._position_footer +
                                      self._position_footer),
            {'Cr-Commit-Position': [self._position, self._position]})
Beispiel #12
0
  def testFootersBasic(self):
    self.assertEqual(
        git_footers.split_footers('Not-A: footer'),
        (['Not-A: footer'], [], []))
    self.assertEqual(
        git_footers.split_footers('Header\n\nActual: footer'),
        (['Header', ''], ['Actual: footer'], [('Actual', 'footer')]))
    self.assertEqual(
        git_footers.split_footers('\nActual: footer'),
        ([''], ['Actual: footer'], [('Actual', 'footer')]))

    self.assertEqual(
        git_footers.parse_footers(self._message), {})
    self.assertEqual(
        git_footers.parse_footers(self._message + self._position_footer),
        { 'Cr-Commit-Position': [ self._position ] })
    self.assertEqual(
        git_footers.parse_footers(self._message + self._git_svn_id_footer),
        { 'Git-Svn-Id': [ self._git_svn_id ] })
    self.assertEqual(
        git_footers.parse_footers(self._message + self._position_footer
                                                + self._position_footer),
        { 'Cr-Commit-Position': [ self._position, self._position ] })
Beispiel #13
0
 def testSplittingLastParagraph(self):
     message = ('Title.\n'
                '\n'
                'The final paragraph has some normal text first.\n'
                'Followed: by\n'
                'nonsense trailers and\n'
                'Some: footers')
     self.assertEqual(git_footers.split_footers(message), ([
         'Title.', '', 'The final paragraph has some normal text first.', ''
     ], ['Followed: by', 'nonsense trailers and', 'Some: footers'
         ], [('Followed', 'by'), ('Some', 'footers')]))
     self.assertEqual(git_footers.parse_footers(message), {
         'Followed': ['by'],
         'Some': ['footers']
     })
Beispiel #14
0
 def testAvoidingURLs(self):
     message = ('Someone accidentally put a URL in the footers.\n'
                '\n'
                'Followed: by\n'
                'http://domain.tld\n'
                'Some: footers')
     self.assertEqual(
         git_footers.split_footers(message),
         (['Someone accidentally put a URL in the footers.', ''], [
             'Followed: by', 'http://domain.tld', 'Some: footers'
         ], [('Followed', 'by'), ('Some', 'footers')]))
     self.assertEqual(git_footers.parse_footers(message), {
         'Followed': ['by'],
         'Some': ['footers']
     })
Beispiel #15
0
 def testAvoidingURLs(self):
   message = ('Someone accidentally put a URL in the footers.\n'
              '\n'
              'Followed: by\n'
              'http://domain.tld\n'
              'Some: footers')
   self.assertEqual(git_footers.split_footers(message),
                    (['Someone accidentally put a URL in the footers.',
                      ''],
                     ['Followed: by',
                      'http://domain.tld',
                      'Some: footers'],
                     [('Followed', 'by'),
                      ('Some', 'footers')]))
   self.assertEqual(git_footers.parse_footers(message),
                    {'Followed': ['by'],
                     'Some': ['footers']})
Beispiel #16
0
 def testSplittingLastParagraph(self):
   message = ('Title.\n'
              '\n'
              'The final paragraph has some normal text first.\n'
              'Followed: by\n'
              'nonsense trailers and\n'
              'Some: footers')
   self.assertEqual(git_footers.split_footers(message),
                    (['Title.',
                      '',
                      'The final paragraph has some normal text first.',
                      ''],
                     ['Followed: by',
                      'nonsense trailers and',
                      'Some: footers'],
                     [('Followed', 'by'),
                      ('Some', 'footers')]))
   self.assertEqual(git_footers.parse_footers(message),
                    {'Followed': ['by'],
                     'Some': ['footers']})
Beispiel #17
0
def main(argv):
  # No command line flags. Just use the parser to prevent people from trying
  # to pass flags that don't do anything, and to provide 'usage'.
  parser = argparse.ArgumentParser(
      description='Automatically set up git-svn for a repo mirrored from svn.')
  parser.parse_args(argv[1:])

  upstream = root()
  message = run_git('log', '-1', '--format=%B', upstream)
  footers = parse_footers(message)
  git_svn_id = get_unique(footers, 'git-svn-id')
  match = GIT_SVN_ID_PATTERN.match(git_svn_id)
  assert match, 'No valid git-svn-id footer found on %s.' % upstream
  print 'Found git-svn-id footer %s on %s' % (match.group(1), upstream)

  parsed_svn = urlparse.urlparse(match.group(1))
  path_components = parsed_svn.path.split('/')
  svn_repo = None
  svn_path = None
  for i in xrange(len(path_components)):
    try:
      maybe_repo = '%s://%s%s' % (
          parsed_svn.scheme, parsed_svn.netloc, '/'.join(path_components[:i+1]))
      print 'Checking ', maybe_repo
      run_svn('info', maybe_repo)
      svn_repo = maybe_repo
      svn_path = '/'.join(path_components[i+1:])
      break
    except subprocess2.CalledProcessError:
      continue
  assert svn_repo is not None, 'Unable to find svn repo for %s' % match.group(1)
  print 'Found upstream svn repo %s and path %s' % (svn_repo, svn_path)

  prefix = upstream.rsplit('/')[0]
  run_git('svn', 'init', '--prefix=%s' % prefix, '-T', svn_path, svn_repo)
  set_config('svn-remote.svn.fetch',
             '%s:refs/remotes/%s' % (svn_path, upstream))
  print 'Configured metadata, running "git svn fetch". This may take some time.'
  for line in run_git_stream('svn', 'fetch').xreadlines():
    print line.strip()
Beispiel #18
0
def main(argv):
    # No command line flags. Just use the parser to prevent people from trying
    # to pass flags that don't do anything, and to provide 'usage'.
    parser = argparse.ArgumentParser(
        description='Automatically set up git-svn for a repo mirrored from svn.'
    )
    parser.parse_args(argv[1:])

    upstream = root()
    message = run_git('log', '-1', '--format=%B', upstream)
    footers = parse_footers(message)
    git_svn_id = get_unique(footers, 'git-svn-id')
    match = GIT_SVN_ID_PATTERN.match(git_svn_id)
    assert match, 'No valid git-svn-id footer found on %s.' % upstream
    print 'Found git-svn-id footer %s on %s' % (match.group(1), upstream)

    parsed_svn = urlparse.urlparse(match.group(1))
    path_components = parsed_svn.path.split('/')
    svn_repo = None
    svn_path = None
    for i in xrange(len(path_components)):
        try:
            maybe_repo = '%s://%s%s' % (parsed_svn.scheme, parsed_svn.netloc,
                                        '/'.join(path_components[:i + 1]))
            print 'Checking ', maybe_repo
            run_svn('info', maybe_repo)
            svn_repo = maybe_repo
            svn_path = '/'.join(path_components[i + 1:])
            break
        except subprocess2.CalledProcessError, e:
            if 'E170001' in str(e):
                print 'Authentication failed:'
                print e
                print(
                    'Try running "svn ls %s" with the password'
                    ' from https://chromium-access.appspot.com' % maybe_repo)
                print
            continue
Beispiel #19
0
def main(argv):
  # No command line flags. Just use the parser to prevent people from trying
  # to pass flags that don't do anything, and to provide 'usage'.
  parser = argparse.ArgumentParser(
      description='Automatically set up git-svn for a repo mirrored from svn.')
  parser.parse_args(argv)

  upstream = root()
  message = run_git('log', '-1', '--format=%B', upstream)
  footers = parse_footers(message)
  git_svn_id = get_unique(footers, 'git-svn-id')
  match = GIT_SVN_ID_PATTERN.match(git_svn_id)
  assert match, 'No valid git-svn-id footer found on %s.' % upstream
  print 'Found git-svn-id footer %s on %s' % (match.group(1), upstream)

  parsed_svn = urlparse.urlparse(match.group(1))
  path_components = parsed_svn.path.split('/')
  svn_repo = None
  svn_path = None
  for i in xrange(len(path_components)):
    try:
      maybe_repo = '%s://%s%s' % (
          parsed_svn.scheme, parsed_svn.netloc, '/'.join(path_components[:i+1]))
      print 'Checking ', maybe_repo
      run_svn('info', maybe_repo)
      svn_repo = maybe_repo
      svn_path = '/'.join(path_components[i+1:])
      break
    except subprocess2.CalledProcessError, e:
      if 'E170001' in str(e):
        print 'Authentication failed:'
        print e
        print ('Try running "svn ls %s" with the password'
               ' from https://chromium-access.appspot.com' % maybe_repo)
        print
      continue