Skip to content

Templating feature#9

Merged
bjester merged 6 commits intomainfrom
templating
Feb 16, 2026
Merged

Templating feature#9
bjester merged 6 commits intomainfrom
templating

Conversation

@bjester
Copy link
Owner

@bjester bjester commented Feb 16, 2026

Summary

  • Adds templating feature with variable replacement
  • Refactors shared functionality between templates and hooks into new class
  • Refactors create command tests

@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 new templating feature, enabling automated file generation within new worktrees with dynamic variable substitution. This enhancement streamlines the setup of new development environments by allowing predefined configurations and scripts to be automatically applied. Concurrently, the underlying architecture has been improved by refactoring shared logic into a new base class, promoting cleaner code and easier maintenance. The changes also include updates to existing command tests to ensure comprehensive coverage of the new functionality.

Highlights

  • Templating Feature Added: Introduced a new templating feature that allows users to define files with variable replacement, which are then copied into new worktrees upon creation or checkout.
  • Shared Functionality Refactored: Extracted common logic for iterating through configuration directories (used by both hooks and templates) into a new ConfigOperator base class, improving code organization and reusability.
  • Create Command Tests Refactored: Updated and refactored the tests for the create command to align with the new templating functionality and improve test structure.
Changelog
  • .gitignore
    • Added a new entry for .aiassistant/ to ignore AI assistant-related files.
  • README.md
    • Updated the feature list to mark 'Worktree templates' as available, removing the 'coming soon' tag.
    • Added a new templates/ directory to the .gh/worktree/ structure in the documentation.
    • Added a new 'Templates' section to the documentation, explaining how to use templates, variable replacement, and allowed environment variables.
  • src/gh_worktree/commands/checkout.py
    • Integrated the _runtime.templates.copy() call into the __call__ method to copy templates when checking out a worktree.
  • src/gh_worktree/commands/create.py
    • Integrated the _runtime.templates.copy() call into the __call__ method to copy templates when creating a worktree.
  • src/gh_worktree/config.py
    • Imported List from typing.
    • Added a new allowed_envvars property to the GlobalConfig class to manage environment variables permitted for template substitution.
  • src/gh_worktree/hooks.py
    • Imported ConfigOperator.
    • Refactored the Hooks class to inherit from ConfigOperator.
    • Updated the fire method to use self.iter_config_dirs() for iterating through hook directories, leveraging the new shared logic.
  • src/gh_worktree/operator.py
    • Added a new file introducing the ConfigOperator base class, which provides shared logic for iterating through global and project-specific configuration directories.
  • src/gh_worktree/runtime.py
    • Imported the new Templates class.
    • Added a templates attribute to the __slots__ of the Runtime class.
    • Initialized the templates attribute with a new Templates instance.
  • src/gh_worktree/templates.py
    • Added a new file defining the Templates class, responsible for copying template files into worktrees and performing variable substitution.
  • tests/commands/test_checkout.py
    • Added a mock for self.templates in the setUp method.
    • Added assertions for self.templates.copy() calls in various test methods.
    • Renamed test methods from test_checkout_command_uses_... to test_call__uses_... for consistency.
  • tests/commands/test_create.py
    • Imported TestCase from unittest.
    • Refactored the test functions into a CreateCommandTestCase class inheriting from TestCase.
    • Added a mock for self.templates in the setUp method.
    • Added assertions for self.templates.copy() calls in various test methods.
    • Renamed test methods from test_create_command_uses_... to test_call__uses_... for consistency.
  • tests/test_templates.py
    • Added a new test file containing a comprehensive test suite for the Templates class, covering initialization, variable substitution, file copying, permission preservation, and directory handling.
Activity
  • No specific activity (comments, reviews, or progress updates) has been recorded for 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

This pull request introduces a valuable templating feature that copies files into new worktrees and replaces variables. It also includes a nice refactoring that extracts shared logic from the Hooks class into a new ConfigOperator base class, which is then used by both Hooks and the new Templates class. The tests have been thoughtfully updated, and new tests for the templating feature have been added. The changes are well-structured, and the new feature is a great addition. I have a couple of suggestions for improvement in the new templates.py file and its tests to enhance performance and test accuracy.

bjester and others added 2 commits February 16, 2026 07:59
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@bjester bjester merged commit f7a86ae into main Feb 16, 2026
10 checks passed
@bjester bjester deleted the templating branch February 16, 2026 16:00
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