Skip to content

Allow bin/github_changelog_generator to be invoked from a path outside the repo #947

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

Open
magneland opened this issue Mar 26, 2021 · 1 comment

Comments

@magneland
Copy link
Contributor

Is your feature request related to a problem? Please describe.
As part of my local development workflow, I would like to make some code changes to this repo, and quickly run the generator on another gem for testing it out.
I tried this command locally (note the cwd is outside the forked repo):

magne@C02ZV1LNMD6W af_json_api % /Users/magne/github/magneland/github-changelog-generator/bin/github_changelog_generator --base CHANGELOG.md --token TOKEN --user USER --project af_json_api
Traceback (most recent call last):
	4: from /Users/magne/github/magneland/github-changelog-generator/bin/github_changelog_generator:4:in `<main>'
	3: from /Users/magne/github/magneland/github-changelog-generator/bin/github_changelog_generator:4:in `require_relative'
	2: from /Users/magne/github/magneland/github-changelog-generator/lib/github_changelog_generator.rb:13:in `<top (required)>'
	1: from /Users/magne/.rvm/rubies/ruby-2.7.1/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:155:in `require'
/Users/magne/.rvm/rubies/ruby-2.7.1/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:155:in `require': cannot load such file -- github_changelog_generator/helper (LoadError)

The error happens because files in lib/ use the "require" directive to include other files in lib/.

Incidentally, bin/github_changelog_generator already makes use of require_relative so that is already a pattern.

Describe the solution you'd like
Use require_relative instead of require.

Describe alternatives you've considered
Not sure if there's a better way or a workaround?

Additional context
See: rubocop/rubocop#8748

@olleolleolle
Copy link
Collaborator

Have you attempted to use the Bundler feature "local"? It allows Bundler to recognize a path on your computer as "the" resolution for a gem in a Gemfile.

If you add a Gemfile to the gem you wish to test (it probably exists already), and then, add a gem "github_changelog_generator" in there, when you run the command in the "other gem" project, Bundler will pick your cool-and-edited work instead of "whatever files it otherwise would find".

Another way is to use "bundle open" on this gem, and edit its files in place, and then undo those changes when done.

There also is the Gemfile option "path", which can be used together with the git" or "github" options. That allows you to use a git checkout of this gem, and make changes and have them reflected in the "other gem" project's Bundler resolution.

Hope these workflow notes help you find a way which assists with what you want to achieve.

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

No branches or pull requests

2 participants