Skip to content

Commit 1d18b76

Browse files
nammnfealebenpae
authored andcommitted
- handle fork (#4178)
# Summary - some sub-commands of detecting the original branch will not work in a fork. Piping all to true ## Proof of Work - https://spruce.mongodb.com/task/ops_manager_kubernetes_run_pre_commit_run_precommit_and_push_patch_bcd12dc59be1fb83328262689e2b199cc2b08ceb_67ceb328658a1e000760d748_25_03_10_09_38_52/logs?execution=0 ``` [2025/03/10 10:39:47.037] Fork: Could not determine the original branch. Running in a fork ``` ## Checklist - [ ] Have you linked a jira ticket and/or is the ticket in the title? - [ ] Have you checked whether your jira ticket required DOCSP changes? - [ ] Have you checked for release_note changes? ## Reminder (Please remove this when merging) - Please try to Approve or Reject Changes the PR, keep PRs in review as short as possible - Our Short Guide for PRs: [Link](https://docs.google.com/document/d/1T93KUtdvONq43vfTfUt8l92uo4e4SEEvFbIEKOxGr44/edit?tab=t.0) - Remember the following Communication Standards - use comment prefixes for clarity: * **blocking**: Must be addressed before approval. * **follow-up**: Can be addressed in a later PR or ticket. * **q**: Clarifying question. * **nit**: Non-blocking suggestions. * **note**: Side-note, non-actionable. Example: Praise * --> no prefix is considered a question
1 parent 98fcea7 commit 1d18b76

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

scripts/evergreen/precommit_bump.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ source scripts/dev/set_env_context.sh
55

66
export GOLANGCI_LINT_CACHE="${HOME}/.cache/golangci-lint"
77

8+
ORIGINAL_BRANCH=""
89
# Detect the original branch (same commit, but not the evg-pr-test-* branch which evg creates)
9-
ORIGINAL_BRANCH=$(git for-each-ref --format='%(refname:short) %(objectname)' refs/remotes/origin | grep "$(git rev-parse HEAD)" | grep -v "evg-pr-test-" | awk '{print $1}' | sed 's|^origin/||' | head -n 1)
10+
ORIGINAL_BRANCH=$(git for-each-ref --format='%(refname:short) %(objectname)' refs/remotes/origin | grep "$(git rev-parse HEAD)" | grep -v "evg-pr-test-" | awk '{print $1}' | sed 's|^origin/||' | head -n 1 || true)
1011

1112
if [[ -z "${ORIGINAL_BRANCH}" ]]; then
12-
echo "Error: Could not determine the original branch."
13-
exit 1
13+
echo "Fork: Could not determine the original branch. Running in a fork"
14+
exit 0
1415
fi
1516
echo "Detected original branch: ${ORIGINAL_BRANCH}"
1617

0 commit comments

Comments
 (0)