Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion ci/run_conditional_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ elif [[ ${BUILD_TYPE} == "presubmit" ]]; then
# For presubmit build, we want to know the difference from the
# common commit in the target branch.
if [ -n "${TARGET_BRANCH}" ]; then
git fetch origin "${TARGET_BRANCH}" --depth=200 || true
if [[ "${TEST_TYPE}" == "import_profile" ]]; then
git fetch origin "${TARGET_BRANCH}:refs/remotes/origin/${TARGET_BRANCH}" || true
else
git fetch origin "${TARGET_BRANCH}:refs/remotes/origin/${TARGET_BRANCH}" --depth=200 || true
fi
Comment on lines +57 to +61

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if [[ "${TEST_TYPE}" == "import_profile" ]]; then
git fetch upstream "${TARGET_BRANCH}" 2>/dev/null || git fetch origin "${TARGET_BRANCH}" || true
else
git fetch upstream "${TARGET_BRANCH}" --depth=200 2>/dev/null || git fetch origin "${TARGET_BRANCH}" --depth=200 || true
fi
if [[ "${TEST_TYPE}" == "import_profile" ]]; then
git fetch origin "${TARGET_BRANCH}:refs/remotes/origin/${TARGET_BRANCH}" || true
else
git fetch origin "${TARGET_BRANCH}:refs/remotes/origin/${TARGET_BRANCH}" --depth=200 || true
fi

Since we do not need to support external forks upstream, we can target origin directly. Gemini also suggested this edit

fi
GIT_DIFF_ARG="origin/${TARGET_BRANCH}..."

Expand Down
12 changes: 8 additions & 4 deletions ci/run_single_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,14 @@ case ${TEST_TYPE} in
BASELINE_CSV="${PROFILER_TEMP_DIR}/baseline_${PACKAGE_NAME}.csv"

if [ -n "${TARGET_BRANCH}" ]; then
# Try upstream first (for forks), then origin
BASELINE_COMMIT=$(git merge-base HEAD "upstream/${TARGET_BRANCH}" 2>/dev/null || \
git merge-base HEAD "origin/${TARGET_BRANCH}" 2>/dev/null || \
git merge-base HEAD "${TARGET_BRANCH}" 2>/dev/null || true)
# Fetch history for the target branch without --depth=1 in case it was shallowly fetched
if [ -f "$(git rev-parse --git-dir)/shallow" ]; then
git fetch origin "${TARGET_BRANCH}:refs/remotes/origin/${TARGET_BRANCH}" --unshallow 2>/dev/null || \
git fetch origin "${TARGET_BRANCH}:refs/remotes/origin/${TARGET_BRANCH}" 2>/dev/null || true
fi
Comment on lines +141 to +145

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar feedback as my other comment

Suggested change
# Fetch history for the target branch without --depth=1 in case it was shallowly fetched
if [ -f "$(git rev-parse --git-dir)/shallow" ]; then
git fetch upstream "${TARGET_BRANCH}" --unshallow 2>/dev/null || \
git fetch origin "${TARGET_BRANCH}" --unshallow 2>/dev/null || \
git fetch upstream "${TARGET_BRANCH}" 2>/dev/null || \
git fetch origin "${TARGET_BRANCH}" 2>/dev/null || true
fi
# Fetch history for the target branch without --depth=1 in case it was shallowly fetched
if [ -f "$(git rev-parse --git-dir)/shallow" ]; then
git fetch origin "${TARGET_BRANCH}:refs/remotes/origin/${TARGET_BRANCH}" --unshallow 2>/dev/null || \
git fetch origin "${TARGET_BRANCH}:refs/remotes/origin/${TARGET_BRANCH}" 2>/dev/null || true
fi

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplified the unshallow fetch to target origin directly with the explicit refspec.

# Try origin first, then fallback to HEAD if everything else fails
BASELINE_COMMIT=$(git merge-base HEAD "origin/${TARGET_BRANCH}" 2>/dev/null || \
git rev-parse HEAD)
if [ -n "${BASELINE_COMMIT}" ]; then
echo "Checking out baseline commit ${BASELINE_COMMIT} in a temporary worktree..."
REPO_PREFIX=$(git rev-parse --show-prefix)
Expand Down
Loading