voxpupuli / modulesync

Synchronize common files across your Git repositories.
Apache License 2.0
104 stars 48 forks source link

Refactor code for maintainabilty #206

Closed neomilium closed 2 years ago

neomilium commented 3 years ago

This PR improves code structure to help owners to maintain the code and contributors to add features.

About the maintainability, this PR attempts to:

This PR also adds tests for bump, tag and changelog features.

To help contributors, this PR renames some methods with IMHO more explicit names and organizes code into classes.

Even msync have been made to manage Puppet modules, there are some users which use it for other purpose (e.g. @raphink wrote https://dev.to/camptocamp-ops/templating-puppet-control-repositories-3pk7) so I started to split specific code into PuppetModule class, while generic one is now in SourceCode class.

More details in commit logs.

neomilium commented 3 years ago

This PR have been flagged as draft due to its dependency on #202 and #204.

neomilium commented 3 years ago

This PR is so big... I started to split it to speed up review and merges.

neomilium commented 3 years ago

212 is the first part.

@ekohl I have some unexpected spare time to contribute to modulesync this day, quicker parts are merged, more will be.

neomilium commented 3 years ago

This PR is stalled, waiting #219 to be merged.

codecov[bot] commented 3 years ago

Codecov Report

Merging #206 (5a03a6d) into master (5b33600) will increase coverage by 1.16%. The diff coverage is 86.84%.

:exclamation: Current head 5a03a6d differs from pull request most recent head 627fffa. Consider uploading reports for the commit 627fffa to get more accurate results Impacted file tree graph

@@            Coverage Diff             @@
##           master     #206      +/-   ##
==========================================
+ Coverage   84.76%   85.93%   +1.16%     
==========================================
  Files          30       30              
  Lines         906      917      +11     
==========================================
+ Hits          768      788      +20     
+ Misses        138      129       -9     
Impacted Files Coverage Δ
lib/modulesync/git_service.rb 70.58% <50.00%> (+16.24%) :arrow_up:
lib/modulesync/source_code.rb 97.50% <50.00%> (-2.50%) :arrow_down:
lib/modulesync/git_service/factory.rb 92.30% <80.00%> (+1.39%) :arrow_up:
lib/modulesync/git_service/base.rb 90.47% <90.90%> (+0.47%) :arrow_up:
lib/modulesync/cli.rb 100.00% <100.00%> (ø)
lib/modulesync/git_service/gitlab.rb 100.00% <100.00%> (ø)
lib/modulesync/repository.rb 93.20% <100.00%> (+0.13%) :arrow_up:
spec/helpers/faker/puppet_module_remote_repo.rb 87.20% <100.00%> (ø)
spec/unit/modulesync/git_service_spec.rb 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 5b33600...627fffa. Read the comment docs.

neomilium commented 3 years ago

To end the story, this PR have been split in several PRs:

Its now time to append some various improvements I noted during refactoring.