Skip to content

Conversation

@dmihalcik-virtru
Copy link
Member

No description provided.

@dmihalcik-virtru dmihalcik-virtru requested review from a team as code owners October 3, 2025 18:46
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @dmihalcik-virtru, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refines the CI cleanup script by integrating more robust Git worktree management. The changes ensure that all Git worktree registrations are properly removed and any orphaned worktree entries are pruned, leading to a cleaner and more reliable CI environment. This prevents potential issues with lingering Git configurations after cleanup operations.

Highlights

  • Enhanced Worktree Cleanup: The cleanup script now explicitly removes Git worktrees using git worktree remove for each branch directory before deleting them, ensuring proper Git state management.
  • Orphaned Worktree Pruning: A new step has been added to prune orphaned worktree registrations using git worktree prune for each SDK's bare repository, preventing accumulation of stale worktree data.
  • Dynamic Bare Repo Path Resolution: A new shell function, get_bare_repo_path, was introduced to dynamically determine the correct bare Git repository path for different SDKs (JavaScript, Java, Go).
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 3, 2025

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request improves the CI cleanup script by correctly handling git worktrees, using worktree remove and worktree prune. This is a good enhancement to prevent stale worktree metadata. My review includes two suggestions for further improvement: one to address code duplication for maintainability by centralizing SDK path definitions, and another to refine the worktree removal logic to be more efficient and less verbose in the logs.

Comment on lines +7 to +23
get_bare_repo_path() {
local sdk=$1
case "$sdk" in
js)
echo "$SCRIPT_DIR/../js/src/web-sdk.git"
;;
java)
echo "$SCRIPT_DIR/../java/src/java-sdk.git"
;;
go)
echo "$SCRIPT_DIR/../go/src/otdfctl.git"
;;
*)
echo ""
;;
esac
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This get_bare_repo_path function duplicates logic from xtest/sdk/scripts/checkout-sdk-branch.sh for determining the bare repository path for each SDK. This duplication can lead to maintenance issues, as changes to SDK paths or names would need to be updated in both files.

To improve maintainability, consider consolidating this logic into a single, shared script or configuration file that both checkout-sdk-branch.sh and this script can use. For example, you could create a helper script that sets environment variables for the paths based on the SDK language.

Comment on lines +37 to 40
if ! git --git-dir="$bare_repo_path" worktree remove "$branch" --force; then
echo "Failed to remove worktree: $sdk#$branch"
fi
rm -rf "$branch"
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The current logic for removing worktrees can be simplified and made less noisy. The git worktree remove command will fail and print an error if a directory is not a worktree, which creates unnecessary noise in the logs. Additionally, the rm -rf "$branch" command is redundant if git worktree remove succeeds, as it already removes the directory.

A cleaner approach is to attempt worktree remove and, only if it fails (for any reason, including not being a worktree), then fall back to rm -rf. This avoids the redundant call and suppresses unnecessary error messages for non-worktree directories.

Suggested change
if ! git --git-dir="$bare_repo_path" worktree remove "$branch" --force; then
echo "Failed to remove worktree: $sdk#$branch"
fi
rm -rf "$branch"
if ! git --git-dir="$bare_repo_path" worktree remove "$branch" --force 2>/dev/null; then
# If worktree remove fails (e.g., not a worktree), fall back to rm -rf.
rm -rf "$branch"
fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant