Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
Scripts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
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
Specification Tools
Scripts
Commits
c16e9201
Commit
c16e9201
authored
8 months ago
by
Miguel Angel Reina Ortega
Browse files
Options
Downloads
Patches
Plain Diff
Adding support to detect conflicts
parent
0346db4d
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
checking_conflicts.sh
+99
-0
99 additions, 0 deletions
checking_conflicts.sh
generateChangemarks/.gitlab-ci.yml
+31
-2
31 additions, 2 deletions
generateChangemarks/.gitlab-ci.yml
with
130 additions
and
2 deletions
checking_conflicts.sh
0 → 100644
+
99
−
0
View file @
c16e9201
#!/bin/bash
#Parameters
#${CI_API_V4_URL} -> 1
echo
"CI_API_V4_URL:"
$1
#${CI_MERGE_REQUEST_PROJECT_ID} -> 2
echo
"CI_MERGE_REQUEST_PROJECT_ID:"
$2
#${CI_MERGE_REQUEST_MILESTONE} -> 3
echo
"CI_MERGE_REQUEST_MILESTONE:"
$3
#${CI_MERGE_REQUEST_TARGET_BRANCH_NAME} -> 4
echo
"CI_MERGE_REQUEST_TARGET_BRANCH_NAME:"
$4
#${CI_MERGE_REQUEST_IID} -> 5
echo
"CI_MERGE_REQUEST_IID:"
$5
#${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME} -> 6
echo
"CI_MERGE_REQUEST_SOURCE_BRANCH_NAME:"
$6
#${CI_PROJECT_NAME} -> 7
echo
"CI_PROJECT_NAME:"
$7
#"$GITLAB_USER_NAME" -> 8
echo
"GITLAB_USER_NAME:"
$8
#$GITLAB_USER_EMAIL -> 9
echo
"GITLAB_USER_EMAIL:"
$9
#echo "------ Removing previous outputs --------"
rm
**
/
*
.txt
#echo "------ Parsing repo URL --------"
#HOST_URL=$(echo $1 | cut -d'/' -f 1-3)
#PROJECT_NAME=$(echo $1 | cut -d'/' -f 6- | cut -d'.' -f 1)
#echo "HOST URL:" $HOST_URL
#echo "PROJECT NAME:" $PROJECT_NAME
#echo "PROJECT ID:" $2
#echo "MERGE IID:" $3
#echo "\n------ Install necessary packages --------"
#pip install -q mkdocs-material mike rich mkdocs-rss-plugin
echo
"------ Config git and checkout project actual merge request source branch --------"
#git clone "https://oauth2:${10}@git.onem2m.org/specifications/ts/${7}.git" ${7}
cd
${
7
}
git config
--global
--replace-all
user.name
"
$8
"
git config
--global
--replace-all
user.email
$9
echo
"Checkout merge request source branch
${
6
}
..."
git checkout
-b
"
${
6
}
"
"origin/
${
6
}
"
#Git checkout actual merge requests SOURCE BRANCHE
git status
echo
"
\n
------ Getting all potential conflicting merge requests --------"
# Get a list of open merge requests: Filter by the same Milestone and Target Branch as the actual merge request
#curl --header "PRIVATE-TOKEN: ${10}" "${1}/projects/${2}/merge_requests?state=opened&milestone=${3}&target_branch=${4}" |jq -c '.[] | {iid: .iid, source_branch: .source_branch, title: .title}'
#curl --header "PRIVATE-TOKEN: ${10}" "${1}/projects/${2}/merge_requests?state=opened&milestone=${3}&target_branch=${4}" | jq -c '.[]' | while read mr; do
#merge_requests=$(curl --header "PRIVATE-TOKEN: ${10}" "${1}/projects/${2}/merge_requests?state=opened&milestone=${3}&target_branch=${4}")
merge_requests
=
$(
curl
"
${
1
}
/projects/
${
2
}
/merge_requests?state=opened&milestone=
${
3
}
&target_branch=
${
4
}
"
)
echo
"
${
merge_requests
}
"
| jq
-c
'.[]'
|
while
read
mr
;
do
mr_id
=
$(
echo
"
$mr
"
| jq
'.iid'
)
result_id
=
$?
if
[
!
$result_id
==
0
]
;
then
echo
"ERROR: When retrieving merge request id"
continue
fi
mr_title
=
$(
echo
"
$mr
"
| jq
'.title'
)
result_title
=
$?
if
[
!
$result_title
==
0
]
;
then
echo
"ERROR: When retrieving merge request title"
continue
fi
mr_source_branch
=
$(
echo
"
$mr
"
| jq
-r
'.source_branch'
)
result_source_branch
=
$?
if
[
!
$result_source_branch
==
0
]
;
then
echo
"ERROR: When retrieving merge request source branch"
continue
fi
if
[
${
mr_id
}
!=
${
5
}
]
;
then
echo
"Checkout potential merge request source branch
${
mr_source_branch
}
..."
git checkout
-b
"
${
mr_source_branch
}
"
"origin/
${
mr_source_branch
}
"
#Git checkout other merge requests SOURCE BRANCHES
echo
"Run dry merge from potential merge request source branch
${
mr_source_branch
}
into actual merge request source branch
${
6
}
..."
git merge
--no-commit
--no-ff
"
${
6
}
"
#SOURCE BRANCH of the merge request
result
=
$?
if
[
!
$result
==
0
]
;
then
echo
"Merge request title:
${
mr_title
}
, Merge Request ID:
${
mr_id
}
"
>>
conflicting_merge_requests.txt
else
echo
"No conflict with Merge request title:
${
mr_title
}
, Merge Request ID:
${
mr_id
}
"
fi
git merge
--abort
fi
done
if
[
-f
"conflicting_merge_requests.txt"
]
;
then
echo
"List of conflicting merge requests:"
cat
conflicting_merge_requests.txt
mv
conflicting_merge_requests.txt ../conflicting_merge_requests.txt
exit
1
else
exit
0
fi
exit
0
This diff is collapsed.
Click to expand it.
generateChangemarks/.gitlab-ci.yml
+
31
−
2
View file @
c16e9201
...
@@ -16,15 +16,42 @@ workflow:
...
@@ -16,15 +16,42 @@ workflow:
variables
:
variables
:
stages
:
stages
:
-
checking
-
generation
-
generation
-
publication
-
publication
-
web
-
web
Checking conflicts
:
stage
:
checking
rules
:
-
if
:
$CI_MERGE_REQUEST_TITLE !~ /v.*_baseline$/ && $CI_PIPELINE_SOURCE == "merge_request_event"
when
:
always
image
:
python:3.9.18-slim-bullseye
tags
:
-
docker
before_script
:
# Installation of required software
-
apt-get update -qq && apt-get -qq install -y git curl jq > /dev/null
-
|
curl "${CI_API_V4_URL}/projects/$TOOLS_SCRIPTS_PROJECT_ID/repository/files/checking_conflicts%2Esh/raw?ref=master" >> checking_conflicts.sh
-
chmod +x checking_conflicts.sh
-
git clone "https://$CI_SERVER_HOST/$CI_PROJECT_PATH.git" ${CI_PROJECT_NAME}
script
:
-
echo 'Checking conflicts'
-
./checking_conflicts.sh ${CI_API_V4_URL} ${CI_MERGE_REQUEST_PROJECT_ID} ${CI_MERGE_REQUEST_MILESTONE} ${CI_MERGE_REQUEST_TARGET_BRANCH_NAME} ${CI_MERGE_REQUEST_IID} ${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME} ${CI_PROJECT_NAME} "$GITLAB_USER_NAME" $GITLAB_USER_EMAIL
artifacts
:
when
:
on_failure
paths
:
-
conflicting_merge_requests.txt
expose_as
:
'
Checking
conflicts
log'
Word CR
:
Word CR
:
stage
:
generation
stage
:
generation
rules
:
rules
:
-
if
:
$CI_MERGE_REQUEST_TITLE !~ /v.*_baseline$/ && $CI_PIPELINE_SOURCE == "merge_request_event"
-
if
:
$CI_MERGE_REQUEST_TITLE !~ /v.*_baseline$/ && $CI_PIPELINE_SOURCE == "merge_request_event"
when
:
always
when
:
on_success
dependencies
:
[]
when
:
on_success
before_script
:
before_script
:
-
|
-
|
curl "${CI_API_V4_URL}/projects/$TOOLS_SCRIPTS_PROJECT_ID/repository/files/generate_changemarks%2Esh/raw?ref=master" >> generate_changemarks.sh
curl "${CI_API_V4_URL}/projects/$TOOLS_SCRIPTS_PROJECT_ID/repository/files/generate_changemarks%2Esh/raw?ref=master" >> generate_changemarks.sh
...
@@ -50,7 +77,9 @@ Baseline contribution:
...
@@ -50,7 +77,9 @@ Baseline contribution:
stage
:
generation
stage
:
generation
rules
:
rules
:
-
if
:
$CI_MERGE_REQUEST_TITLE =~ /v.*_baseline$/ && $CI_PIPELINE_SOURCE == "merge_request_event"
-
if
:
$CI_MERGE_REQUEST_TITLE =~ /v.*_baseline$/ && $CI_PIPELINE_SOURCE == "merge_request_event"
when
:
always
when
:
on_success
dependencies
:
[]
when
:
on_success
before_script
:
before_script
:
-
|
-
|
curl "${CI_API_V4_URL}/projects/$TOOLS_SCRIPTS_PROJECT_ID/repository/files/publish_spec%2Esh/raw?ref=master" >> publish_spec.sh
curl "${CI_API_V4_URL}/projects/$TOOLS_SCRIPTS_PROJECT_ID/repository/files/publish_spec%2Esh/raw?ref=master" >> publish_spec.sh
...
...
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