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

Use a less error-prone way of specifying gem files #662

Merged
merged 2 commits into from
Oct 1, 2019

Conversation

mattbrictson
Copy link
Contributor

Before, whenever a new file is added to lib, the contributor or maintainer has to remember to explicitly add it to the gemspec. If this step is forgotten, it results in a broken release, like #657.

This commit makes this process less error prone by using git ls-files to automatically include all appropriate files in the gem. This is in line with what is advocated by Bundler's gem template:

https://github.com/bundler/bundler/blob/2a4d88a7044528209321fd4441e995ec66f604b9/lib/bundler/templates/newgem/newgem.gemspec.tt#L26

To test this PR I ran rake gem and verified that the list of files included in the gem is the same as before:

AUTHORS.rdoc
CHANGELOG.rdoc
README.rdoc
RELEASE.rdoc
TODO.rdoc
annotate.gemspec
bin/annotate
lib/annotate.rb
lib/annotate/active_record_patch.rb
lib/annotate/annotate_models.rb
lib/annotate/annotate_routes.rb
lib/annotate/constants.rb
lib/annotate/parser.rb
lib/annotate/tasks.rb
lib/annotate/version.rb
lib/generators/annotate/USAGE
lib/generators/annotate/install_generator.rb
lib/generators/annotate/templates/auto_annotate_models.rake
lib/tasks/annotate_models.rake
lib/tasks/annotate_models_migrate.rake
lib/tasks/annotate_routes.rake

Before, whenever a new file is added to `lib`, the contributor or
maintainer has to remember to explicitly add it to the gemspec. If this
step is forgotten, it results in a broken release, like ctran#657.

This commit makes this process less error prone by using `git ls-files`
to automatically include all appropriate files in the gem. This is in
line with what is advocated by Bundler's gem template:

https://github.com/bundler/bundler/blob/2a4d88a7044528209321fd4441e995ec66f604b9/lib/bundler/templates/newgem/newgem.gemspec.tt#L26
@drwl
Copy link
Collaborator

drwl commented Sep 30, 2019

@mattbrictson oh wow this is neat, thanks for the PR. Having this would have definitely prevented an issue like #657. Two things:

  1. looks like it's just missing LICENSE.txt, should be an easy fix.
  2. what's the difference between using the -z flag and splitting on \x0 compared to not using -z flag and splitting on \n, for example like how Pry does it?

@drwl drwl added the reviewed label Sep 30, 2019
@mattbrictson
Copy link
Contributor Author

looks like it's just missing LICENSE.txt, should be an easy fix.

Nice catch, I'll add it.

what's the difference between using the -z flag and splitting on \x0 compared to not using -z flag and splitting on \n, for example like how Pry does it?

I assume that if you run the code on a Windows machine then the line ending will not be \n, so it would break in that environment. The -z is therefore more robust across platforms.

Alternatively you could require "English" and then split on $RS (the platform-specific line separator), but the -z trick is a lot more concise.

@drwl drwl merged commit 9c91d50 into ctran:develop Oct 1, 2019
@drwl
Copy link
Collaborator

drwl commented Oct 1, 2019

Gotcha thanks for the explanation, I learned something 🙂.

@mattbrictson mattbrictson deleted the better-gemspec-files branch October 1, 2019 04:01
peterfication pushed a commit to store2be/annotate_models that referenced this pull request Jan 20, 2020
Before, whenever a new file is added to `lib`, the contributor or
maintainer has to remember to explicitly add it to the gemspec. If this
step is forgotten, it results in a broken release, like ctran#657.

This commit makes this process less error prone by using `git ls-files`
to automatically include all appropriate files in the gem. This is in
line with what is advocated by Bundler's gem template:

https://github.com/bundler/bundler/blob/2a4d88a7044528209321fd4441e995ec66f604b9/lib/bundler/templates/newgem/newgem.gemspec.tt#L26
vfonic pushed a commit to vfonic/annotate_models that referenced this pull request May 8, 2020
Before, whenever a new file is added to `lib`, the contributor or
maintainer has to remember to explicitly add it to the gemspec. If this
step is forgotten, it results in a broken release, like ctran#657.

This commit makes this process less error prone by using `git ls-files`
to automatically include all appropriate files in the gem. This is in
line with what is advocated by Bundler's gem template:

https://github.com/bundler/bundler/blob/2a4d88a7044528209321fd4441e995ec66f604b9/lib/bundler/templates/newgem/newgem.gemspec.tt#L26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants