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

feat(remotes): add remotes and configs #609

Merged
merged 3 commits into from
Jan 22, 2024

Conversation

NikitaCOEUR
Copy link
Contributor

@NikitaCOEUR NikitaCOEUR commented Jan 13, 2024

Closes # (issue)

No issues closed by this, but a complement of : #343 /
#420

⚡ Summary

Evolution of remote configuration, enabling the integration of multiple configurations from one or more different repositories.

Example :

# lefthook.yml

remotes:
  - git_url: git@github.com:evilmartians/remote
    ref: v1.0.0
    configs:
      - examples/ruby-linter.yml
      - examples/test.yml
  - git_url : https://github.com:example/repository
    configs:
      - lefthooks/pre_commit.yml
      - lefthooks/post_merge.yml
  - git_url : https://github.com:example2/repository2
    ref: specific_branch
    configs:
      - example/pre-push.yml

I have retained the old functionality with a single remote and a single config, which is still operational (but deprecated).

I needed to add an exclusion of gocyclo for the TestLoad function (internal/config/load_test.go) because it was reporting excessively high complexity. However, it doesn't seem critical since it's an addition of a test for the new feature.

Additionally, I tried to add deprecation messages for those still using 'remote' and 'config,' but it breaks the tests. Do you have a solution to avoid this?

I hope this work suits you well; feel free to provide feedback if needed!

☑️ Checklist

  • Check locally
  • Add tests
  • Add documentation

@mrexox
Copy link
Member

mrexox commented Jan 15, 2024

Wow, that's an amazing work! Thank you a lot! I will take a look at the PR this week and come back with the feedback.

Copy link
Member

@mrexox mrexox left a comment

Choose a reason for hiding this comment

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

Amazing work! Thank you for the PR. I have fixed a few places that I considered important. I think the PR is pretty done. I will take a look at it one more time a bit later and merge it.

The only concern for me is merging extends for different remotes. I will try to figure out how to fix it (if I reproduce this issue of course)

Comment on lines +183 to +185
if err = extend(v, filepath.Dir(configPath)); err != nil {
return err
}
Copy link
Member

Choose a reason for hiding this comment

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

Looks like we will extend the same things multiple times, and if files from different remotes have extends it will break here.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, I've tested this concern and I coundn't reproduce an error, because extends get replaced after merging each remote. That's fine. I will polish the PR a little bit and prepare it for the release.

Comment on lines 135 to 137
if cfg.Remote != nil {
cfg.Remotes = append(cfg.Remotes, cfg.Remote)
}
Copy link
Member

Choose a reason for hiding this comment

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

This can be done in load.go

@mrexox mrexox merged commit f49b54a into evilmartians:master Jan 22, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants