[EWS] ShowIdentifier should support pull-requests
https://bugs.webkit.org/show_bug.cgi?id=235252
<rdar://problem/87618736>

Reviewed by Aakash Jain.

* Tools/CISupport/ews-build/steps.py:
(ShowIdentifier.start): Extract revision from diverse set of properties.
(ShowIdentifier.evaluateCommand):
* Tools/CISupport/ews-build/steps_unittest.py:

Canonical link: https://commits.webkit.org/246066@main

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@288040 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Tools/CISupport/ews-build/steps.py b/Tools/CISupport/ews-build/steps.py
index 5600466..7037add 100644
--- a/Tools/CISupport/ews-build/steps.py
+++ b/Tools/CISupport/ews-build/steps.py
@@ -407,9 +407,15 @@
     def start(self):
         self.log_observer = logobserver.BufferLogObserver()
         self.addLogObserver('stdio', self.log_observer)
-        revision = self.getProperty('ews_revision', self.getProperty('got_revision'))
-        if not revision:
-            revision = 'HEAD'
+
+        revision = 'HEAD'
+        # Note that these properties are delibrately in priority order.
+        for property_ in ['ews_revision', 'github.base.sha', 'got_revision']:
+            candidate = self.getProperty(property_)
+            if candidate:
+                revision = candidate
+                break
+
         self.setCommand(['python3', 'Tools/Scripts/git-webkit', 'find', revision])
         return shell.ShellCommand.start(self)
 
diff --git a/Tools/CISupport/ews-build/steps_unittest.py b/Tools/CISupport/ews-build/steps_unittest.py
index d4b31c7..f031032 100644
--- a/Tools/CISupport/ews-build/steps_unittest.py
+++ b/Tools/CISupport/ews-build/steps_unittest.py
@@ -4852,6 +4852,39 @@
         self.assertEqual(self.getProperty('identifier'), '233175@main')
         return rc
 
+    def test_success_pull_request(self):
+        self.setupStep(ShowIdentifier())
+        self.setProperty('github.base.sha', '51a6aec9f664')
+        self.expectRemoteCommands(
+            ExpectShell(workdir='wkdir',
+                        timeout=300,
+                        logEnviron=False,
+                        command=['python3', 'Tools/Scripts/git-webkit', 'find', '51a6aec9f664']) +
+            ExpectShell.log('stdio', stdout='Identifier: 233175@main') +
+            0,
+        )
+        self.expectOutcome(result=SUCCESS, state_string='Identifier: 233175@main')
+        rc = self.runStep()
+        self.assertEqual(self.getProperty('identifier'), '233175@main')
+        return rc
+
+    def test_prioritized(self):
+        self.setupStep(ShowIdentifier())
+        self.setProperty('ews_revision', '51a6aec9f664')
+        self.setProperty('github.base.sha', '9f66451a6aec')
+        self.expectRemoteCommands(
+            ExpectShell(workdir='wkdir',
+                        timeout=300,
+                        logEnviron=False,
+                        command=['python3', 'Tools/Scripts/git-webkit', 'find', '51a6aec9f664']) +
+            ExpectShell.log('stdio', stdout='Identifier: 233175@main') +
+            0,
+        )
+        self.expectOutcome(result=SUCCESS, state_string='Identifier: 233175@main')
+        rc = self.runStep()
+        self.assertEqual(self.getProperty('identifier'), '233175@main')
+        return rc
+
     def test_failure(self):
         self.setupStep(ShowIdentifier())
         self.expectRemoteCommands(
diff --git a/Tools/ChangeLog b/Tools/ChangeLog
index 68ddf13..abf050d 100644
--- a/Tools/ChangeLog
+++ b/Tools/ChangeLog
@@ -1,3 +1,16 @@
+2022-01-14  Jonathan Bedard  <jbedard@apple.com>
+
+        [EWS] ShowIdentifier should support pull-requests
+        https://bugs.webkit.org/show_bug.cgi?id=235252
+        <rdar://problem/87618736>
+
+        Reviewed by Aakash Jain.
+
+        * CISupport/ews-build/steps.py:
+        (ShowIdentifier.start): Extract revision from diverse set of properties.
+        (ShowIdentifier.evaluateCommand):
+        * CISupport/ews-build/steps_unittest.py:
+
 2022-01-14  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         [iOS] Occasional crash under -[UITargetedPreview initWithView:parameters:target:] when focusing form controls