Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include repo object when templating #303

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

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
@@ -123,7 +123,7 @@ export default class Git {

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

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.

None yet

2 participants