Skip to content

Commit

Permalink
[git-webkit] Use label size in reverts
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=273691
rdar://127495362

Reviewed by Aakash Jain.

* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/revert.py:
(Revert.create_revert_commit_msg): Use 12 character hash.
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/revert_unittest.py:
(TestRevert.webserver):
(test_update):
(test_pr):
(test_land_safe):
(test_land_unsafe):

Canonical link: https://commits.webkit.org/278465@main
  • Loading branch information
JonWBedard committed May 7, 2024
1 parent b72f1b6 commit 628e24b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def create_revert_commit_msg(cls, args, commit_objects, **kwargs):
reverted_changeset += '\n {}\n'.format(commit_title)
reverted_changeset += '\n'.join(bug_urls)
if commit.identifier and commit.branch:
commit_repr = '{}@{} ({})'.format(commit.identifier, commit.branch, commit.hash[:7])
commit_repr = '{}@{} ({})'.format(commit.identifier, commit.branch, commit.hash[:commit.HASH_LABEL_SIZE])
reverted_commits.append(commit_repr)
reverted_changeset += '\n {}\n'.format(commit_repr)
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def webserver(cls, approved=None, labels=None, environment=None):
1: dict(
number=1,
opened=True,
title='Unreviewed, reverting 5@main (d8bce26)',
title='Unreviewed, reverting 5@main (d8bce26fa65c)',
description='?',
creator=result.users.create(name='Tim Contributor', username='tcontributor'),
timestamp=1639536160,
Expand All @@ -61,7 +61,7 @@ def webserver(cls, approved=None, labels=None, environment=None):
result.pull_requests = [dict(
number=1,
state='open',
title='Unreviewed, reverting 5@main (d8bce26)',
title='Unreviewed, reverting 5@main (d8bce26fa65c)',
user=dict(login='tcontributor'),
body='''#### a5fe8afe9bf7d07158fcd9e9732ff02a712db2fd
<pre>
Expand Down Expand Up @@ -102,15 +102,15 @@ def test_github(self):
self.assertEqual(0, result)
self.assertDictEqual(repo.modified, dict())
self.assertDictEqual(repo.staged, dict())
self.assertEqual(True, 'Unreviewed, reverting 5@main (d8bce26)' in repo.head.message)
self.assertEqual(True, 'Unreviewed, reverting 5@main (d8bce26fa65c)' in repo.head.message)
self.assertEqual(local.Git(self.path).remote().pull_requests.get(1).draft, False)

self.assertEqual(
captured.stdout.getvalue(),
"This issue will track the revert and should not be the issue of the commit(s) to be reverted.\n"
"Enter issue URL or title of new issue (reason for the revert): \n"
"Created the local development branch 'eng/Example-feature-1'\n"
"Created 'PR 1 | Unreviewed, reverting 5@main (d8bce26)'!\n"
"Created 'PR 1 | Unreviewed, reverting 5@main (d8bce26fa65c)'!\n"
"https://github.example.com/WebKit/WebKit/pull/1\n",
)
self.assertEqual(captured.stderr.getvalue(), '')
Expand Down Expand Up @@ -151,7 +151,7 @@ def test_github_two_step(self):
self.assertEqual(0, result)
self.assertDictEqual(repo.modified, dict())
self.assertDictEqual(repo.staged, dict())
self.assertEqual(True, 'Unreviewed, reverting 5@main (d8bce26)' in repo.head.message)
self.assertEqual(True, 'Unreviewed, reverting 5@main (d8bce26fa65c)' in repo.head.message)
with MockTerminal.input('{}/show_bug.cgi?id=2'.format(self.BUGZILLA)):
result = program.main(args=('pull-request', '-v', '--no-history'), path=self.path)
self.assertEqual(0, result)
Expand All @@ -162,7 +162,7 @@ def test_github_two_step(self):
"This issue will track the revert and should not be the issue of the commit(s) to be reverted.\n"
"Enter issue URL or title of new issue (reason for the revert): \n"
"Created the local development branch 'eng/Example-feature-1'\n"
"Created 'PR 1 | Unreviewed, reverting 5@main (d8bce26)'!\n"
"Created 'PR 1 | Unreviewed, reverting 5@main (d8bce26fa65c)'!\n"
"https://github.example.com/WebKit/WebKit/pull/1\n",
)
self.assertEqual(captured.stderr.getvalue(), '')
Expand Down Expand Up @@ -204,7 +204,7 @@ def test_args(self):
self.assertEqual(0, result)
self.assertDictEqual(repo.modified, dict())
self.assertDictEqual(repo.staged, dict())
self.assertEqual(True, 'Unreviewed, reverting 5@main (d8bce26)' in repo.head.message)
self.assertEqual(True, 'Unreviewed, reverting 5@main (d8bce26fa65c)' in repo.head.message)
with MockTerminal.input('{}/show_bug.cgi?id=2'.format(self.BUGZILLA)):
result = program.main(args=('pull-request', '-v', '--no-history'), path=self.path)
self.assertEqual(0, result)
Expand All @@ -213,7 +213,7 @@ def test_args(self):
self.assertEqual(
captured.stdout.getvalue(),
"Created the local development branch 'eng/Example-feature-1'\n"
"Created 'PR 1 | Unreviewed, reverting 5@main (d8bce26)'!\n"
"Created 'PR 1 | Unreviewed, reverting 5@main (d8bce26fa65c)'!\n"
"https://github.example.com/WebKit/WebKit/pull/1\n",
)
self.assertEqual(captured.stderr.getvalue(), '')
Expand Down Expand Up @@ -290,9 +290,9 @@ def test_update(self):
"This issue will track the revert and should not be the issue of the commit(s) to be reverted.\n"
"Enter issue URL or title of new issue (reason for the revert): \n"
"Created the local development branch 'eng/Example-feature-1'\n"
"Created 'PR 1 | Unreviewed, reverting 5@main (d8bce26)'!\n"
"Created 'PR 1 | Unreviewed, reverting 5@main (d8bce26fa65c)'!\n"
"https://github.example.com/WebKit/WebKit/pull/1\n"
"Updated 'PR 1 | Unreviewed, reverting 5@main (d8bce26)'!\n"
"Updated 'PR 1 | Unreviewed, reverting 5@main (d8bce26fa65c)'!\n"
"https://github.example.com/WebKit/WebKit/pull/1\n",
)
self.assertEqual(captured.stderr.getvalue(), '')
Expand Down Expand Up @@ -345,11 +345,11 @@ def test_pr(self):
self.assertEqual(0, result)
self.assertDictEqual(repo.modified, dict())
self.assertDictEqual(repo.staged, dict())
self.assertEqual(True, 'Unreviewed, reverting 5@main (d8bce26)' in repo.head.message)
self.assertEqual(True, 'Unreviewed, reverting 5@main (d8bce26fa65c)' in repo.head.message)
self.assertEqual(
captured.stdout.getvalue(),
"Created the local development branch 'eng/Example-feature-1'\n"
"Created 'PR 1 | Unreviewed, reverting 5@main (d8bce26)'!\n"
"Created 'PR 1 | Unreviewed, reverting 5@main (d8bce26fa65c)'!\n"
"https://github.example.com/WebKit/WebKit/pull/1\n"
)

Expand Down Expand Up @@ -396,7 +396,7 @@ def test_land_safe(self):
"Pushing 'eng/Example-issue-1' to 'fork'...",
"Creating 'eng/Example-issue-1-1' as a reference branch",
"Creating pull-request for 'eng/Example-issue-1'...",
"Adding 'merge-queue' to 'PR 2 | Unreviewed, reverting 5@main (d8bce26)'",
"Adding 'merge-queue' to 'PR 2 | Unreviewed, reverting 5@main (d8bce26fa65c)'",
],
)

Expand Down Expand Up @@ -443,6 +443,6 @@ def test_land_unsafe(self):
"Pushing 'eng/Example-issue-1' to 'fork'...",
"Creating 'eng/Example-issue-1-1' as a reference branch",
"Creating pull-request for 'eng/Example-issue-1'...",
"Adding 'unsafe-merge-queue' to 'PR 2 | Unreviewed, reverting 5@main (d8bce26)'",
"Adding 'unsafe-merge-queue' to 'PR 2 | Unreviewed, reverting 5@main (d8bce26fa65c)'",
],
)

0 comments on commit 628e24b

Please sign in to comment.