Skip to content

Conversation

@kenodegard
Copy link

This change adds the repo object to every Nunjucks context for easier bulk templating.

The way templating is currently defined makes it very verbose to template several repos, especially when trying to do relatively simple templating like injecting the repo name. We'd effectively need:

# sync.yml

user/repo1:
  - source: src/README.md
    template:
      user: user
      repo: repo1

user/repo2:
  - source: src/README.md
    template:
      user: user
      repo: repo2

...
# README.md

Hello from {{ repo }} by {{ user }}!

By pre-populating the context with the repo object we are able to simplify it and do the following instead:

# sync.yml

group:
  - repos: |
      user/repo1
      user/repo2
      ...
    files:
      - source: src/README.md
        template: true
# README.md

Hello from {{ repo.name }} by {{ repo.user }}!

@kenodegard
Copy link
Author

@BetaHuhn will you have time to review this soon?

src/git.js Outdated
async getBaseBranch() {
this.baseBranch = await execCmd(
`git rev-parse --abbrev-ref HEAD`,
`git branch --show-current`,
Copy link
Owner

Choose a reason for hiding this comment

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

@kenodegard why are these changes to the git.js file necessary?

Copy link
Author

Choose a reason for hiding this comment

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

I can't remember, but it wouldn't appear necessary and can be reverted

Copy link
Author

Choose a reason for hiding this comment

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

Reverted in 2ddece4

@kenodegard kenodegard force-pushed the template-constants branch from 8c82d01 to 2da9fa8 Compare May 6, 2024 14:03
@azrod
Copy link

azrod commented Dec 27, 2024

Hi,

Any update for this great feature ?

@DariuszPorowski
Copy link

Hi @BetaHuhn

Any updates? :)

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