Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
450c1446
Unverified
Commit
450c1446
authored
Feb 01, 2024
by
Matt Solomon
Committed by
GitHub
Feb 02, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ci: extract PR number from merge queue branch names for better diffs (#9308)
parent
14e7889e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
0 deletions
+18
-0
main.py
ops/check-changed/main.py
+18
-0
No files found.
ops/check-changed/main.py
View file @
450c1446
...
...
@@ -75,6 +75,15 @@ def main():
pr_urls
=
os
.
getenv
(
'CIRCLE_PULL_REQUESTS'
,
None
)
pr_urls
=
pr_urls
.
split
(
','
)
if
pr_urls
else
[]
# If we successfully extracted a PR number and did not find PRs from CIRCLE_PULL_REQUESTS,
# we are on a merge queue branch and can reconstruct the original PR URL from the PR number.
pr_number
=
extract_pr_number
(
current_branch
)
if
not
pr_urls
and
pr_number
is
not
None
:
log
.
info
(
'No PR URLs found but extracted branch number, constructing PR URL'
)
base_url
=
"https://github.com/ethereum-optimism/optimism/pull/"
pr_urls
=
[
base_url
+
pr_number
]
if
len
(
pr_urls
)
==
0
:
log
.
info
(
'Not a PR build, triggering build'
)
exit_build
()
...
...
@@ -126,6 +135,15 @@ def match_path(path, patterns):
return
True
return
False
def
extract_pr_number
(
branch_name
):
# Merge queue branches are named: gh-readonly-queue/{base_branch}/pr-{number}-{sha}
match
=
re
.
search
(
r'/pr-(\d+)-'
,
branch_name
)
if
match
:
pr_number
=
match
.
group
(
1
)
log
.
info
(
'Extracted PR number:
%
s'
,
pr_number
)
return
pr_number
else
:
return
None
def
exit_build
():
sys
.
exit
(
0
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment