Modified: trunk/Tools/CISupport/ews-build/steps.py (289505 => 289506)
--- trunk/Tools/CISupport/ews-build/steps.py 2022-02-09 22:59:13 UTC (rev 289505)
+++ trunk/Tools/CISupport/ews-build/steps.py 2022-02-09 23:48:48 UTC (rev 289506)
@@ -91,7 +91,7 @@
return '{}/pull/{}'.format(repository_url, pr_number)
@classmethod
- def commit_url(cls, sha, repository_url=None):
+ def commit_url(cls, sha, repository_url=None, pr_number=None):
if not repository_url:
repository_url = '{}{}'.format(GITHUB_URL, GITHUB_PROJECTS[0])
if repository_url not in GitHub.repository_urls():
@@ -98,6 +98,8 @@
return ''
if not sha:
return ''
+ if pr_number:
+ return '{}/pull/{}/commits/{}'.format(repository_url, pr_number, sha)
return '{}/commit/{}'.format(repository_url, sha)
@classmethod
@@ -328,7 +330,7 @@
display_name = '{} ({})'.format(display_name, github_username)
self.addURL('PR by: {}'.format(display_name), '{}{}'.format(GITHUB_URL, github_username))
if revision:
- self.addURL('Hash: {}'.format(revision[:HASH_LENGTH_TO_DISPLAY]), GitHub.commit_url(revision, repository_url))
+ self.addURL('Hash: {}'.format(revision[:HASH_LENGTH_TO_DISPLAY]), GitHub.commit_url(revision, repository_url, pr_number))
class CheckOutSource(git.Git):
Modified: trunk/Tools/CISupport/ews-build/steps_unittest.py (289505 => 289506)
--- trunk/Tools/CISupport/ews-build/steps_unittest.py 2022-02-09 22:59:13 UTC (rev 289505)
+++ trunk/Tools/CISupport/ews-build/steps_unittest.py 2022-02-09 23:48:48 UTC (rev 289506)
@@ -46,7 +46,7 @@
CleanBuild, CleanUpGitIndexLock, CleanGitRepo, CleanWorkingDirectory, CompileJSC, CompileJSCWithoutChange,
CompileWebKit, CompileWebKitWithoutChange, ConfigureBuild, ConfigureBuild, Contributors, CreateLocalGITCommit,
DownloadBuiltProduct, DownloadBuiltProductFromMaster, EWS_BUILD_HOSTNAME, ExtractBuiltProduct, ExtractTestResults,
- FetchBranches, FindModifiedChangeLogs, FindModifiedLayoutTests, GitResetHard,
+ FetchBranches, FindModifiedChangeLogs, FindModifiedLayoutTests, GitHub, GitResetHard,
InstallBuiltProduct, InstallGtkDependencies, InstallWpeDependencies,
KillOldProcesses, PrintConfiguration, PushCommitToWebKitRepo, ReRunAPITests, ReRunWebKitPerlTests,
ReRunWebKitTests, RevertPullRequestChanges, RunAPITests, RunAPITestsWithoutPatch, RunBindingsTests, RunBuildWebKitOrgUnitTests,
@@ -214,6 +214,50 @@
return behavior
+class TestGitHub(unittest.TestCase):
+ def test_pr_url(self):
+ self.assertEqual(
+ GitHub.pr_url(1234),
+ 'https://github.com/WebKit/WebKit/pull/1234',
+ )
+
+ def test_pr_url_with_repository(self):
+ self.assertEqual(
+ GitHub.pr_url(1234, 'https://github.com/WebKit/WebKit'),
+ 'https://github.com/WebKit/WebKit/pull/1234',
+ )
+
+ def test_pr_url_with_invalid_repository(self):
+ self.assertEqual(
+ GitHub.pr_url(1234, 'https://github.example.com/WebKit/WebKit'),
+ '',
+ )
+
+ def test_commit_url(self):
+ self.assertEqual(
+ GitHub.commit_url('936e3f7cab4a826519121a75bf4481fe56e727e2'),
+ 'https://github.com/WebKit/WebKit/commit/936e3f7cab4a826519121a75bf4481fe56e727e2',
+ )
+
+ def test_commit_url_with_repository(self):
+ self.assertEqual(
+ GitHub.commit_url('936e3f7cab4a826519121a75bf4481fe56e727e2', 'https://github.com/WebKit/WebKit'),
+ 'https://github.com/WebKit/WebKit/commit/936e3f7cab4a826519121a75bf4481fe56e727e2',
+ )
+
+ def test_commit_url_with_invalid_repository(self):
+ self.assertEqual(
+ GitHub.commit_url('936e3f7cab4a826519121a75bf4481fe56e727e2', 'https://github.example.com/WebKit/WebKit'),
+ '',
+ )
+
+ def test_pr_commit_url(self):
+ self.assertEqual(
+ GitHub.commit_url('936e3f7cab4a826519121a75bf4481fe56e727e2', pr_number=1234),
+ 'https://github.com/WebKit/WebKit/pull/1234/commits/936e3f7cab4a826519121a75bf4481fe56e727e2',
+ )
+
+
class TestStepNameShouldBeValidIdentifier(BuildStepMixinAdditions, unittest.TestCase):
def test_step_names_are_valid(self):
import steps