Skip to content

Conversation

@blooop
Copy link
Owner

@blooop blooop commented Jan 17, 2026

Summary by Sourcery

Regenerate the Pixi lockfile after template merges and project renaming instead of force-keeping the existing file, and exclude the lockfile from bulk search-and-replace operations during project rename.

Enhancements:

  • Update the template sync script to regenerate and commit pixi.lock after merging template changes.
  • Adjust the project rename script to avoid renaming inside pixi.lock and trigger a Pixi lockfile regeneration afterward.

@sourcery-ai
Copy link

sourcery-ai bot commented Jan 17, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts template update and project rename scripts to regenerate pixi.lock instead of force-keeping the old version, and prevents blind string replacement inside the lockfile.

Sequence diagram for updated template synchronization script

sequenceDiagram
    actor Developer
    participant Script as update_from_template_sh
    participant Git
    participant Pixi

    Developer->>Script: run update_from_template.sh
    Script->>Git: fetch --all
    Script->>Git: checkout main
    Script->>Git: pull origin main
    Script->>Git: checkout -B feature/update_from_template
    Script->>Git: pull
    Script->>Git: merge template/main --allow-unrelated-histories
    Script->>Git: checkout --ours pixi.lock
    Script->>Pixi: pixi update
    Pixi-->>Script: regenerate pixi.lock based on merged pyproject_toml
    Script->>Git: add pixi.lock
    Script->>Git: diff --cached --quiet
    alt lockfile changed
        Script->>Git: commit -m chore: update pixi.lock after template merge
    end
    Script->>Git: remote remove template
    Script->>Git: push --set-upstream origin feature/update_from_template
    Script->>Git: checkout main
    Script-->>Developer: script complete
Loading

Flow diagram for updated project rename script behavior

flowchart TD
    A[Start rename_project_sh] --> B[Move directory python_template to new_name]
    B --> C[Find files excluding .git directory]
    C --> D[Exclude files named tasks.json]
    D --> E[Exclude files named update_from_template.sh]
    E --> F[Exclude file named pixi.lock]
    F --> G[Perform sed replacement python_template -> new_name on remaining files]
    G --> H[Run pixi update]
    H --> I[Regenerate pixi.lock for renamed project]
    I --> J{Author name provided}
    J -->|Yes| K[Replace author placeholders]
    J -->|No| L[Skip author replacement]
    K --> M[End]
    L --> M[End]
Loading

File-Level Changes

Change Details Files
Update the template sync script to regenerate pixi.lock after merging from the template instead of always preserving the local version.
  • Stop staging pixi.lock immediately after forcing our version during the merge.
  • Run pixi update after the merge so the lockfile matches the merged pyproject.toml.
  • Stage the regenerated pixi.lock and conditionally create a commit only if pixi.lock changes.
  • Keep the rest of the template merge workflow (branch setup, remote removal, push) unchanged.
scripts/update_from_template.sh
Update the project rename script to avoid editing pixi.lock and to refresh it after renaming the project.
  • Exclude pixi.lock from the recursive sed-based project name substitution to avoid corrupting the lockfile.
  • Run pixi update after renaming the project so the lockfile is regenerated with the new project name.
  • Preserve the existing behavior for renaming the project directory and updating other files.
scripts/rename_project.sh

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • Both scripts now assume pixi is installed and available on PATH; consider adding an explicit check with a clear error message (e.g., command -v pixi >/dev/null || { echo 'pixi is required'; exit 1; }) to fail fast when it is missing.
  • In rename_project.sh, pixi update will currently run unconditionally; consider guarding it with a check for pixi.lock or the expected project files so the script behaves more predictably when run in an unexpected directory.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Both scripts now assume `pixi` is installed and available on `PATH`; consider adding an explicit check with a clear error message (e.g., `command -v pixi >/dev/null || { echo 'pixi is required'; exit 1; }`) to fail fast when it is missing.
- In `rename_project.sh`, `pixi update` will currently run unconditionally; consider guarding it with a check for `pixi.lock` or the expected project files so the script behaves more predictably when run in an unexpected directory.

## Individual Comments

### Comment 1
<location> `scripts/rename_project.sh:6` </location>
<code_context>

 # change project name in all files
-find . \( -type d -name .git -prune \) -o \( -type f -not -name 'tasks.json' -not -name 'update_from_template.sh'  \) -print0 | xargs -0 sed -i "s/python_template/$1/g"
+find . \( -type d -name .git -prune \) -o \( -type f -not -name 'tasks.json' -not -name 'update_from_template.sh' -not -name 'pixi.lock' \) -print0 | xargs -0 sed -i "s/python_template/$1/g"
+
+# regenerate lockfile to match renamed project
</code_context>

<issue_to_address>
**issue:** Handle project names with characters that are special to sed

Using `sed -i "s/python_template/$1/g"` will fail or corrupt replacements when `$1` contains `/`, `&`, or other sed metacharacters. If arbitrary project names are expected, either restrict/validate allowed characters in `$1`, properly escape `$1` before passing it to sed, or switch to a safer mechanism (e.g., perl with `quotemeta` or a different sed delimiter plus escaping).
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@blooop blooop enabled auto-merge January 17, 2026 15:54
@blooop blooop merged commit 89d4168 into main Jan 17, 2026
7 checks passed
@blooop blooop deleted the feature/fix_update_from_template branch January 17, 2026 15:54
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.

2 participants