Skip to content

Conversation

@vgpopov
Copy link
Contributor

@vgpopov vgpopov commented Dec 1, 2025

No description provided.

@changeset-bot
Copy link

changeset-bot bot commented Dec 1, 2025

⚠️ No Changeset found

Latest commit: 9341e7d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @vgpopov, 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 significantly enhances the batch block dependency update tooling by introducing a dedicated script for changeset generation, improving the robustness of repository cloning and dependency installation, and streamlining the pull request creation workflow. These changes aim to make the dependency update process more reliable, efficient, and user-friendly through better branch management, existing PR detection, and clearer script interactions.

Highlights

  • New create-changeset.sh Script: A dedicated script has been added to automate the creation of changeset files for npm packages within monorepos, supporting branch-specific naming and conditional generation based on changes from the main branch.
  • Improved Repository Cloning and Dependency Installation: The clone-milab-open.sh script now uses git pull --rebase for cleaner history and includes more robust error handling for directory changes and pnpm install, ensuring package.json existence before attempting installation.
  • Enhanced main.sh Command Management: The main script now includes a new create-changeset command, refines the start command to manage branch names via a update-deps.txt file, and updates the finish command to read branch information and prompt for confirmation before restoring stashed changes.
  • Refined Dependency Replacement Logic: The replace_deps.sh script has been updated to exclude common lock files (like pnpm-lock.yaml, package-lock.json, etc.) from its search, preventing unintended modifications to these files.
  • Streamlined PR Creation in update-deps.sh: The update-deps.sh script now integrates the new create-changeset.sh for changeset generation, uses pnpm install --no-frozen-lockfile, and features improved PR creation logic that checks for existing pull requests, handles PR URL extraction from errors, and tracks created PRs in a dedicated file.
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.

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 significantly improves the batch dependency update scripts by adding documentation, modularizing the changeset creation logic, and making the PR creation process more robust. I've identified a few areas with bugs or opportunities for simplification to enhance maintainability and efficiency. Key issues include a bug in a log message, redundant code for reading branch names, and a logic error that incorrectly overwrites the PR tracking file. Overall, these are great improvements.

Comment on lines +197 to +200
if [[ -z "$BRANCH" ]]; then
DEFAULT_BRANCH="$BRANCH_FROM_FILE"
msg_info "Using existing branch '$BRANCH' from update-deps.txt"
fi
Copy link
Contributor

Choose a reason for hiding this comment

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

high

There's a bug in this log message. '$BRANCH' will be empty, leading to a confusing message like Using existing branch '' from update-deps.txt. Also, the if [[ -z "$BRANCH" ]] check is redundant. This logic can be simplified for clarity and correctness.

Suggested change
if [[ -z "$BRANCH" ]]; then
DEFAULT_BRANCH="$BRANCH_FROM_FILE"
msg_info "Using existing branch '$BRANCH' from update-deps.txt"
fi
if [[ -n "$BRANCH_FROM_FILE" ]]; then
DEFAULT_BRANCH="$BRANCH_FROM_FILE"
msg_info "Using existing branch '$DEFAULT_BRANCH' from update-deps.txt as default."
fi


# Summary
if [[ "${#CREATED_PRS[@]}" -gt 0 ]]; then
echo "${CREATED_PRS[@]}" | tee "$PRS_FILE" > /dev/null
Copy link
Contributor

Choose a reason for hiding this comment

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

high

This line overwrites the PRS_FILE with only the pull requests created in the current run, formatted as a single space-separated line. This defeats the purpose of the add_pr_to_file function, which is designed to append PRs and avoid duplicates across multiple runs. This line should be removed to ensure the tracking file works as intended.

@@ -3,4 +3,34 @@
For installation:
```sh
curl
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 curl command for installation is incomplete. This could be confusing for users trying to install the tool. Please provide the full command or remove the placeholder.

Copy link
Member

Choose a reason for hiding this comment

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

??

Comment on lines +135 to +171
# Create changeset file
{
echo '---'
while IFS= read -r name; do
if [ -n "$name" ] && [ "$name" != "undefined" ] && [ "$name" != "null" ]; then
printf '"%s": patch\n' "$name"
fi
done <<< "$ALL_NAMES"
echo '---'
echo ''
echo 'technical release'
} > "$CHANGESET_FILE"

# Verify last entry format is "...": patch and fix if necessary
LAST_ENTRY=$(awk 'flag{ if($0~/---/){exit}; if($0!=""){print} } $0~/---/{flag=1}' "$CHANGESET_FILE" | tail -n 1)

if [[ -z "$LAST_ENTRY" || ! "$LAST_ENTRY" =~ ^\".+\":\ patch$ ]]; then
msg_warn "Invalid last changeset entry: '$LAST_ENTRY'. Attempting to correct..."
GOOD_ENTRIES=$(awk 'flag{ if($0~/---/){exit}; if($0 ~ /^[\t ]*\".*\": patch[\t ]*$/){print} } $0~/---/{flag=1}' "$CHANGESET_FILE")

if [[ -z "$GOOD_ENTRIES" ]]; then
msg_warn "No valid changeset entries found; removing $CHANGESET_FILE"
rm -f "$CHANGESET_FILE"
return 1
else
{
echo '---'
printf "%s\n" "$GOOD_ENTRIES"
echo '---'
echo ''
echo 'technical release'
} > "$CHANGESET_FILE"
msg_success "Changeset corrected in $CHANGESET_FILE"
fi
else
msg_success "Changeset created: $CHANGESET_FILE"
fi
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 block of code for creating and then verifying the changeset file is overly complex and hard to maintain. The use of awk and tail to validate the file content after writing it is fragile. This can be simplified by building the changeset frontmatter in a variable first, which is more readable and less error-prone.

  # Create changeset file
  declare -a frontmatter_lines=()
  while IFS= read -r name; do
    if [[ -n "$name" ]]; then
      frontmatter_lines+=("$(printf '"%s": patch' "$name")")
    fi
  done <<< "$ALL_NAMES"

  if [ ${#frontmatter_lines[@]} -eq 0 ]; then
    msg_warn "No packages found for changeset."
    return 0
  fi

  {
    echo "---"
    printf '%s\n' "${frontmatter_lines[@]}"
    echo "---"
    echo ""
    echo "technical release"
  } > "$CHANGESET_FILE"

  msg_success "Changeset created: $CHANGESET_FILE"

Comment on lines +281 to +292
if [[ -f "$UPDATE_DEPS_FILE" ]]; then
if grep -q "^branch=" "$UPDATE_DEPS_FILE"; then
BRANCH=$(grep "^branch=" "$UPDATE_DEPS_FILE" | cut -d'=' -f2-)
msg_info "Using branch from update-deps.txt: $BRANCH"
else
msg_error "--branch is required (or create update-deps.txt with branch=<name> when on main)"
exit 1
fi
else
msg_error "--branch is required (or create update-deps.txt with branch=<name> when on main)"
exit 1
fi
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 block for reading the branch from update-deps.txt is duplicated in several places (e.g., finish command, update-deps.sh). It can also be simplified to be more concise and avoid redundant else blocks. Consider extracting this logic into a helper function to improve maintainability.

Suggested change
if [[ -f "$UPDATE_DEPS_FILE" ]]; then
if grep -q "^branch=" "$UPDATE_DEPS_FILE"; then
BRANCH=$(grep "^branch=" "$UPDATE_DEPS_FILE" | cut -d'=' -f2-)
msg_info "Using branch from update-deps.txt: $BRANCH"
else
msg_error "--branch is required (or create update-deps.txt with branch=<name> when on main)"
exit 1
fi
else
msg_error "--branch is required (or create update-deps.txt with branch=<name> when on main)"
exit 1
fi
if [[ -f "$UPDATE_DEPS_FILE" ]] && grep -q "^branch=" "$UPDATE_DEPS_FILE"; then
BRANCH=$(grep "^branch=" "$UPDATE_DEPS_FILE" | cut -d'=' -f2-)
msg_info "Using branch from update-deps.txt: $BRANCH"
else
msg_error "--branch is required (or create update-deps.txt with branch=<name> when on main)"
exit 1
fi

Comment on lines +271 to +272
msg_info "Running pnpm install to ensure dependencies are up to date..."
pnpm install || msg_warn "pnpm install failed in $DIR"
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 pnpm install command here is redundant. An installation is already performed on line 260 if dependency files have changed, which is the primary case for needing to run it. The clone-milab-open.sh script also ensures dependencies are installed initially. Removing this unconditional install will improve script efficiency.

@@ -3,4 +3,34 @@
For installation:
```sh
curl
Copy link
Member

Choose a reason for hiding this comment

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

??


(cd "$target_dir" && pnpm i) || msg_error "Could not install dependencies"
if [ -d "$target_dir" ]; then
if [ -f "$target_dir/package.json" ]; then
Copy link
Member

Choose a reason for hiding this comment

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

Let's also check pnpm-workspace file. platforma-open may keep also repos with single package within.

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.

4 participants