Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.devtools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
bob
bob.devtools
Commits
37b15c72
Commit
37b15c72
authored
6 years ago
by
André Anjos
Browse files
Options
Downloads
Patches
Plain Diff
[release] Ensure merge-when-pipeline-succeeds is properly set
parent
f2a22d74
No related branches found
No related tags found
1 merge request
!16
New commitfile command
Pipeline
#26964
passed
6 years ago
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bob/devtools/release.py
+7
-8
7 additions, 8 deletions
bob/devtools/release.py
bob/devtools/scripts/commitfile.py
+6
-4
6 additions, 4 deletions
bob/devtools/scripts/commitfile.py
with
13 additions
and
12 deletions
bob/devtools/release.py
+
7
−
8
View file @
37b15c72
...
@@ -229,7 +229,7 @@ def update_tag_comments(gitpkg, tag_name, tag_comments_list, dry_run=False):
...
@@ -229,7 +229,7 @@ def update_tag_comments(gitpkg, tag_name, tag_comments_list, dry_run=False):
def
update_files_with_mr
(
gitpkg
,
files_dict
,
message
,
branch
,
automerge
,
def
update_files_with_mr
(
gitpkg
,
files_dict
,
message
,
branch
,
automerge
,
dry_run
):
dry_run
,
user_id
):
"""
Update (via a commit) files of a given gitlab package, through an MR
"""
Update (via a commit) files of a given gitlab package, through an MR
This function can update a file in a gitlab package, but will do this
This function can update a file in a gitlab package, but will do this
...
@@ -244,6 +244,7 @@ def update_files_with_mr(gitpkg, files_dict, message, branch, automerge,
...
@@ -244,6 +244,7 @@ def update_files_with_mr(gitpkg, files_dict, message, branch, automerge,
automerge: If we should set the
"
merge if build suceeds
"
flag on the
automerge: If we should set the
"
merge if build suceeds
"
flag on the
created MR
created MR
dry_run: If True, nothing will be pushed to gitlab
dry_run: If True, nothing will be pushed to gitlab
user_id: The integer which numbers the user to attribute this MR to
"""
"""
...
@@ -268,17 +269,15 @@ def update_files_with_mr(gitpkg, files_dict, message, branch, automerge,
...
@@ -268,17 +269,15 @@ def update_files_with_mr(gitpkg, files_dict, message, branch, automerge,
logger
.
debug
(
"
Creating merge request %s -> master
"
,
branch
)
logger
.
debug
(
"
Creating merge request %s -> master
"
,
branch
)
logger
.
debug
(
"
Set merge-when-pipeline-succeeds = %s
"
,
automerge
)
logger
.
debug
(
"
Set merge-when-pipeline-succeeds = %s
"
,
automerge
)
if
not
dry_run
:
if
not
dry_run
:
mr
=
project
.
mergerequests
.
create
({
mr
=
gitpkg
.
mergerequests
.
create
({
'
source_branch
'
:
branch
,
'
source_branch
'
:
branch
,
'
target_branch
'
:
'
master
'
,
'
target_branch
'
:
'
master
'
,
'
title
'
:
message
,
'
title
'
:
message
,
'
remove_source_branch
'
:
True
,
'
assignee_id
'
:
user_id
,
})
})
accept
=
{
time
.
sleep
(
0.5
)
# to avoid the MR to be merged automatically - bug?
'
merge_when_pipeline_succeeds
'
:
'
true
'
if
automerge
else
'
false
'
,
mr
.
merge
(
merge_when_pipeline_succeeds
=
automerge
)
'
should_remove_source_branch
'
:
'
true
'
,
}
mr
.
merge
(
accept
)
def
update_files_at_master
(
gitpkg
,
files_dict
,
message
,
dry_run
):
def
update_files_at_master
(
gitpkg
,
files_dict
,
message
,
dry_run
):
...
...
This diff is collapsed.
Click to expand it.
bob/devtools/scripts/commitfile.py
+
6
−
4
View file @
37b15c72
...
@@ -57,6 +57,8 @@ def commitfile(package, message, file, path, branch, auto_merge, dry_run):
...
@@ -57,6 +57,8 @@ def commitfile(package, message, file, path, branch, auto_merge, dry_run):
raise
RuntimeError
(
'
PACKAGE should be specified as
"
group/name
"'
)
raise
RuntimeError
(
'
PACKAGE should be specified as
"
group/name
"'
)
gl
=
get_gitlab_instance
()
gl
=
get_gitlab_instance
()
gl
.
auth
()
user_id
=
gl
.
user
.
attributes
[
'
id
'
]
# we lookup the gitlab package once
# we lookup the gitlab package once
use_package
=
gl
.
projects
.
get
(
package
)
use_package
=
gl
.
projects
.
get
(
package
)
...
@@ -75,10 +77,10 @@ def commitfile(package, message, file, path, branch, auto_merge, dry_run):
...
@@ -75,10 +77,10 @@ def commitfile(package, message, file, path, branch, auto_merge, dry_run):
contents
=
f
.
read
()
contents
=
f
.
read
()
components
=
os
.
path
.
splitext
(
path
)[
0
].
split
(
os
.
sep
)
components
=
os
.
path
.
splitext
(
path
)[
0
].
split
(
os
.
sep
)
branch
=
'
update-%s
'
%
components
[
-
1
].
lower
()
branch
=
branch
or
'
update-%s
'
%
components
[
-
1
].
lower
()
message
=
message
or
(
"
[
%s
]
update
"
%
\
message
=
message
or
(
"
%s update
"
%
\
''
.
join
([
'
[%s]
'
%
k
for
k
in
components
]))
''
.
join
([
'
[%s]
'
%
k
.
lower
()
for
k
in
components
]))
# commit and push changes
# commit and push changes
update_files_with_mr
(
use_package
,
{
path
:
contents
},
message
,
branch
,
update_files_with_mr
(
use_package
,
{
path
:
contents
},
message
,
branch
,
auto_merge
,
dry_run
)
auto_merge
,
dry_run
,
user_id
)
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