Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
gitlab-ci
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
4
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SECO Northern Europe
Yocto
infrastructure
gitlab-ci
Commits
daa4cbee
Commit
daa4cbee
authored
2 years ago
by
Jonas Höppner
Browse files
Options
Downloads
Patches
Plain Diff
CI: Move the loop to check if a revision is related to another to common
parent
3e491ba0
No related branches found
No related tags found
1 merge request
!107
CI: deploy_gitlab_ci: Move one-time code to own function as reference
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
check_if_integration_branch_is_up_to_date.py
+3
-13
3 additions, 13 deletions
check_if_integration_branch_is_up_to_date.py
common.py
+31
-0
31 additions, 0 deletions
common.py
with
34 additions
and
13 deletions
check_if_integration_branch_is_up_to_date.py
+
3
−
13
View file @
daa4cbee
...
...
@@ -46,20 +46,10 @@ def check_if_integration_branch_is_up_to_date(
integration_base_id
=
integration_base_branch
.
commit
[
"
id
"
]
parent
=
integration_branch
.
commit
parent
=
manifest_project
.
commits
.
get
(
parent
[
"
id
"
],
retry_transient_errors
=
True
)
# Loop over the commits until the integration_branch head id is found
while
True
:
# The integration branch is up to date if its parent is the integration base
logging
.
debug
(
parent
.
id
)
if
parent
.
id
==
integration_base_id
:
return
True
if
len
(
parent
.
parent_ids
)
==
0
:
break
parent_id
=
parent
.
parent_ids
[
0
]
# Assume linear history
parent
=
manifest_project
.
commits
.
get
(
parent_id
,
retry_transient_errors
=
True
)
return
False
return
common
.
is_commit_parent_of_project_commit
(
manifest_project
,
integration_branch
.
commit
[
"
id
"
],
integration_base_id
)
def
main
():
...
...
This diff is collapsed.
Click to expand it.
common.py
+
31
−
0
View file @
daa4cbee
...
...
@@ -255,3 +255,34 @@ def get_repository_file_obj(project: Project, filename, ref=None):
return
None
fileobj
=
fileobj
[
0
]
return
fileobj
def
is_commit_parent_of_project_commit
(
project
:
Project
,
project_commit
,
commit
):
"""
Walks through the commits of project, starting with project_commit
and compares its sha with the given commit.
Both commits are specified as sha
"""
try
:
_
=
project
.
commits
.
get
(
commit
,
retry_transient_errors
=
True
)
except
GitlabGetError
as
e
:
raise
Exception
(
"
Failed to find commit {} in {}
"
.
format
(
project_commit
,
project
.
name
)
)
from
e
# Loop over the parent commits until commit is found
parent_id
=
project_commit
while
True
:
try
:
parent
=
project
.
commits
.
get
(
parent_id
,
retry_transient_errors
=
True
)
except
GitlabGetError
as
e
:
raise
Exception
(
"
Failed to find commit {} in {}
"
.
format
(
parent_id
,
project
.
name
)
)
from
e
# The integration branch is up to date if its parent is the integration base
logging
.
debug
(
parent
.
id
)
if
parent
.
id
==
commit
:
return
True
if
len
(
parent
.
parent_ids
)
==
0
:
return
False
parent_id
=
parent
.
parent_ids
[
0
]
# Assume linear history
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment