Skip to content

Implement templates copy on project initialization#12

Merged
bjester merged 2 commits intomainfrom
final-initial
Feb 16, 2026
Merged

Implement templates copy on project initialization#12
bjester merged 2 commits intomainfrom
final-initial

Conversation

@bjester
Copy link
Owner

@bjester bjester commented Feb 16, 2026

Summary

  • Adds template initialization that copies project templates from .gh/worktree in the repo

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @bjester, 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 introduces a significant enhancement to the gh-worktree project initialization process by enabling the automatic copying of project templates. When a new project is initialized, the system will now detect and replicate any templates defined within the .gh/worktree/templates directory of the repository's main branch. This streamlines project setup by ensuring that essential template files are readily available in the newly created worktree, improving consistency and reducing manual configuration.

Highlights

  • Template Initialization: Implemented functionality to automatically copy project templates from .gh/worktree/templates in the main branch during project initialization.
  • Template Management API: Introduced a TemplateExists exception and an add context manager in the Templates class to facilitate adding new template files while preventing overwrites.
  • Documentation Update: Updated the README.md to reflect the new project hook and template initialization feature and explain its behavior.
  • Test Coverage: Added comprehensive unit tests to verify the correct installation of templates and the handling of existing template files during initialization.
Changelog
  • README.md
    • Updated the feature list to include "Project hook and template initialization".
    • Added a detailed explanation of how gh-worktree copies templates from .gh/worktree during project initialization.
  • src/gh_worktree/commands/init.py
    • Imported TemplateExists from gh_worktree.templates.
    • Modified the __call__ method to invoke _add_templates before _add_hooks.
    • Implemented the _add_templates method to list, retrieve, and add template files from the default branch, handling TemplateExists exceptions.
  • src/gh_worktree/templates.py
    • Imported contextmanager from contextlib.
    • Defined a new exception class TemplateExists.
    • Added an add context manager method that creates a new template file, raises TemplateExists if the file already exists, and yields a file handle for writing.
  • tests/commands/test_init.py
    • Added a templates mock object to the setUp method.
    • Updated the runtime object to include the templates mock.
    • Added test_call__installs_templates to verify that templates are correctly added during initialization.
    • Added test_add_templates__skips_existing to confirm that existing templates are skipped.
  • tests/test_templates.py
    • Imported TemplateExists.
    • Added test_add__creates_file to verify the add method creates a new template file and writes content.
    • Added test_add__raises_when_existing to confirm that TemplateExists is raised when attempting to add an already existing template.
Activity
  • No human activity (comments, reviews, etc.) has been recorded on this pull request yet.
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.

@github-actions
Copy link

github-actions bot commented Feb 16, 2026

🎉 Build Assets are ready!

File Checksum
gh_worktree-0.1.1-py3-none-any.whl ``
gh-worktree.pex ``

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

The pull request successfully implements template initialization by copying files from the repository's default branch. The changes are well-integrated into the existing command structure and include appropriate test coverage. I have identified a few medium-severity issues related to path handling and line ending configuration that should be addressed to ensure robustness across different environments and file types.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@bjester bjester merged commit c08ef86 into main Feb 16, 2026
10 checks passed
@bjester bjester deleted the final-initial branch February 16, 2026 18:23
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