mirror of
https://gitlab.eurecom.fr/oai/openairinterface5g.git
synced 2026-07-13 04:30:28 +00:00
fix(ci): infer branch name if only commit given
After migration of github, we only use the commit ID for the pre-ci-check script. This is problematic, because it checks for merges, excluding the integration branch (expected to have merges), based on the branch _name_. In this commit, if a full SHA is detected as the branch "name", use "git branch --points-at" to get a branch name, then use that to exclude integration branches (or not). If no branch name is found, the branch name "" is used, which will trigger the normal merge check (because "" does not match the integration branch name). Signed-off-by: Robert Schmidt <robert.schmidt@openairinterface.org>
This commit is contained in:
@@ -55,8 +55,17 @@ done
|
|||||||
# ----------------------------
|
# ----------------------------
|
||||||
# Merged commits
|
# Merged commits
|
||||||
# ----------------------------
|
# ----------------------------
|
||||||
mergeCommits=$(git rev-list --merges --abbrev-commit "$TARGET_BRANCH".."$SOURCE_BRANCH")
|
if [[ "$SOURCE_BRANCH" =~ ^[0-9a-f]{40}$ ]]; then
|
||||||
if [[ ! "$SOURCE_BRANCH" =~ ^(origin/)?integration_[0-9]{4}_w[0-9]{2}$ ]]; then
|
# note: if no branch could be found, it will result in "" and git rev-list
|
||||||
|
# will use the commit ID. Exclude "HEAD detached at", then use first branch
|
||||||
|
# name.
|
||||||
|
BRANCH_NAME=$(git branch -a --points-at $SOURCE_BRANCH --format='%(refname:short)' | grep -v detached | head -n1)
|
||||||
|
echo "SHA recognized in $SOURCE_BRANCH, using \"$BRANCH_NAME\" as branch name"
|
||||||
|
else
|
||||||
|
BRANCH_NAME="$SOURCE_BRANCH"
|
||||||
|
fi
|
||||||
|
if [[ ! "$BRANCH_NAME" =~ ^(origin/)?integration_[0-9]{4}_w[0-9]{2}$ ]]; then
|
||||||
|
mergeCommits=$(git rev-list --merges --abbrev-commit "$TARGET_BRANCH".."$SOURCE_BRANCH")
|
||||||
if [[ -n "$mergeCommits" ]]; then
|
if [[ -n "$mergeCommits" ]]; then
|
||||||
message="Error: Following merge commits are found in the source branch history. Please rebase your branch.\n\n"
|
message="Error: Following merge commits are found in the source branch history. Please rebase your branch.\n\n"
|
||||||
message+="$(echo "$mergeCommits" | paste -sd ',' | sed 's/,/, /g')\n"
|
message+="$(echo "$mergeCommits" | paste -sd ',' | sed 's/,/, /g')\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user