Skip to content

Add default_branch Filter for use on struct templates#22

Merged
httpdss merged 2 commits into
mainfrom
default-branch-filter
Nov 18, 2024
Merged

Add default_branch Filter for use on struct templates#22
httpdss merged 2 commits into
mainfrom
default-branch-filter

Conversation

@httpdss
Copy link
Copy Markdown
Owner

@httpdss httpdss commented Nov 16, 2024

Overview

This PR introduces a new default_branch filter, enabling users to dynamically fetch the default branch name of a specified GitHub repository. This feature enhances the automation and accuracy of project templates.

Changes

  • Documentation:
    • Updated README.md and README.es.md with detailed examples of how to use the default_branch filter.
  • Filter Implementation:
    • Added get_default_branch function in filters.py to fetch the default branch using the GitHub API.
    • Integrated the default_branch filter into the Jinja2 environment in template_renderer.py.
  • Code Adjustments:
    • Updated template_renderer.py to support the new filter.

Justification

The default_branch filter allows users to seamlessly incorporate the default branch name of a GitHub repository into their templates, ensuring consistency and reducing manual input. This feature is particularly useful in CI/CD pipelines and dynamic project configurations.

Impact

  • Improved flexibility and automation in project templates.
  • Requires a valid GitHub token for private repository access, ensuring secure API interactions.
  • Maintains backward compatibility with existing templates.

@httpdss httpdss changed the title Add default_branch filter to retrieve default branch name from GitHub repository Add default_branch Filter for use on struct templates Nov 18, 2024
@httpdss httpdss merged commit 6bf9f40 into main Nov 18, 2024
@httpdss httpdss deleted the default-branch-filter branch November 18, 2024 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant