-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch-mr
More file actions
executable file
·29 lines (22 loc) · 835 Bytes
/
fetch-mr
File metadata and controls
executable file
·29 lines (22 loc) · 835 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/zsh
# https://github.com/b9swift/CI-System
# Copyright (c) 2024 BB9z, MIT License
set -euo pipefail
. "$(dirname "$0")/lib/log.sh"
if [[ -z "${CI_GIT_MR_BRANCH:-}" ]]; then
logWarning "[MergeRequests] CI_GIT_MR_BRANCH not set, skip."
return 0
fi
logInfo "[MergeRequests] Fetching branch $CI_GIT_MR_BRANCH..."
git remote prune origin
git fetch origin "$CI_GIT_MR_BRANCH"
if [[ -n "${CI_CHANGE_LIST_PATH:-}" ]]; then
git diff --name-only HEAD..."origin/$CI_GIT_MR_BRANCH" > "$CI_CHANGE_LIST_PATH"
logInfo "[MergeRequests] Change list saved to $CI_CHANGE_LIST_PATH."
fi
git merge "origin/$CI_GIT_MR_BRANCH" --no-edit --no-commit --no-verify || {
git merge --abort || true
logError "[MergeRequests] Conflict may occur, try to resolve it first."
exit 1
}
logInfo "[MergeRequests] Merge completed."