Exemplo n.º 1
0
 def __missing__(self, path):
   tree = root._replace(treeish=rev, path=path).get_tree()
   if tree is None:
     # Tree is not found. Did the commit disappear?
     if gitiles.get_commit(root.hostname, root.project, rev) is None:
       logging.error('Commit %s disappeared')
       raise CancelTask()
     else:   # pragma: no coverage
       raise Exception('Tree is not found. Retry the task')
   return sorted(tree.entries, key=lambda e: e.name)
Exemplo n.º 2
0
    def test_get_commit(self):
        req_path = 'project/+/%s' % REVISION
        gerrit.fetch_json.return_value = {
            'commit':
            REVISION,
            'tree':
            '3cfb41e1c6c37e61c3eccfab2395752298a5743c',
            'parents': [
                '4087678c002d57e1148f21da5e00867df9a7d973',
            ],
            'author': {
                'name': 'John Doe',
                'email': '*****@*****.**',
                'time': 'Tue Apr 29 00:00:00 2014',
            },
            'committer': {
                'name': 'John Doe',
                'email': '*****@*****.**',
                'time': 'Tue Apr 29 00:00:00 2014',
            },
            'message':
            'Subject\\n\\nBody',
            'tree_diff': [{
                'type': 'modify',
                'old_id': 'f23dec7da271f7e9d8c55a35f32f6971b7ce486d',
                'old_mode': 33188,
                'old_path': 'codereview.settings',
                'new_id': '0bdbda926c49aa3cc4b7248bc22cc261abff5f94',
                'new_mode': 33188,
                'new_path': 'codereview.settings',
            }, {
                'type': 'add',
                'old_id': '0000000000000000000000000000000000000000',
                'old_mode': 0,
                'old_path': '/dev/null',
                'new_id': 'e69de29bb2d1d6434b8b29ae775ad8c2e48c5391',
                'new_mode': 33188,
                'new_path': 'x',
            }],
        }

        commit = gitiles.get_commit(HOSTNAME, PROJECT, REVISION)
        gerrit.fetch_json.assert_called_once_with(HOSTNAME, req_path)
        self.assertIsNotNone(commit)
        self.assertEqual(commit.sha, REVISION)
        self.assertEqual(commit.committer.name, 'John Doe')
        self.assertEqual(commit.committer.email, '*****@*****.**')
        self.assertEqual(commit.author.name, 'John Doe')
        self.assertEqual(commit.author.email, '*****@*****.**')
Exemplo n.º 3
0
  def test_get_commit(self):
    req_path = 'project/+/%s' % REVISION
    self.mock_fetch_json({
      'commit': REVISION,
      'tree': '3cfb41e1c6c37e61c3eccfab2395752298a5743c',
      'parents': [
        '4087678c002d57e1148f21da5e00867df9a7d973',
      ],
      'author': {
        'name': 'John Doe',
        'email': '*****@*****.**',
        'time': 'Tue Apr 29 00:00:00 2014',
      },
      'committer': {
        'name': 'John Doe',
        'email': '*****@*****.**',
        'time': 'Tue Apr 29 00:00:00 2014',
      },
      'message': 'Subject\\n\\nBody',
      'tree_diff': [
        {
          'type': 'modify',
          'old_id': 'f23dec7da271f7e9d8c55a35f32f6971b7ce486d',
          'old_mode': 33188,
          'old_path': 'codereview.settings',
          'new_id': '0bdbda926c49aa3cc4b7248bc22cc261abff5f94',
          'new_mode': 33188,
          'new_path': 'codereview.settings',
        },
        {
          'type': 'add',
          'old_id': '0000000000000000000000000000000000000000',
          'old_mode': 0,
          'old_path': '/dev/null',
          'new_id': 'e69de29bb2d1d6434b8b29ae775ad8c2e48c5391',
          'new_mode': 33188,
          'new_path': 'x',
        }
      ],
    })

    commit = gitiles.get_commit(HOSTNAME, PROJECT, REVISION)
    gerrit.fetch_json_async.assert_called_once_with(HOSTNAME, req_path)
    self.assertIsNotNone(commit)
    self.assertEqual(commit.sha, REVISION)
    self.assertEqual(commit.committer.name, 'John Doe')
    self.assertEqual(commit.committer.email, '*****@*****.**')
    self.assertEqual(commit.author.name, 'John Doe')
    self.assertEqual(commit.author.email, '*****@*****.**')
Exemplo n.º 4
0
    def test_get_commit(self):
        req_path = "project/+/%s" % REVISION
        self.mock_fetch_json(
            {
                "commit": REVISION,
                "tree": "3cfb41e1c6c37e61c3eccfab2395752298a5743c",
                "parents": ["4087678c002d57e1148f21da5e00867df9a7d973"],
                "author": {"name": "John Doe", "email": "*****@*****.**", "time": "Tue Apr 29 00:00:00 2014"},
                "committer": {"name": "John Doe", "email": "*****@*****.**", "time": "Tue Apr 29 00:00:00 2014"},
                "message": "Subject\\n\\nBody",
                "tree_diff": [
                    {
                        "type": "modify",
                        "old_id": "f23dec7da271f7e9d8c55a35f32f6971b7ce486d",
                        "old_mode": 33188,
                        "old_path": "codereview.settings",
                        "new_id": "0bdbda926c49aa3cc4b7248bc22cc261abff5f94",
                        "new_mode": 33188,
                        "new_path": "codereview.settings",
                    },
                    {
                        "type": "add",
                        "old_id": "0000000000000000000000000000000000000000",
                        "old_mode": 0,
                        "old_path": "/dev/null",
                        "new_id": "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391",
                        "new_mode": 33188,
                        "new_path": "x",
                    },
                ],
            }
        )

        commit = gitiles.get_commit(HOSTNAME, PROJECT, REVISION)
        gerrit.fetch_json_async.assert_called_once_with(HOSTNAME, req_path)
        self.assertIsNotNone(commit)
        self.assertEqual(commit.sha, REVISION)
        self.assertEqual(commit.committer.name, "John Doe")
        self.assertEqual(commit.committer.email, "*****@*****.**")
        self.assertEqual(commit.author.name, "John Doe")
        self.assertEqual(commit.author.email, "*****@*****.**")