Giter VIP home page Giter VIP logo

gem_updater's Introduction

Version Build Status Maintainability Codacy Quality Badge Codacy Coverage Badge Inline docs

GemUpdater: update your gemfile and retrieve changelogs

Every week or so, you wish to update your Gemfile, to do so, you just have to launch bundle update.

Problem is updates may break things. And obviously you need to know what may have broke before pushing your code to production. Before running your test suite and checking everything is fine, the first thing you do is probably to look for the changelogs of updated gems.

This process can be quite time consumming: you need to check on the internet for every updated gems, find where their changelog is hosted, and probably link to it in your commit message so that other developers will have a chance to review it too.

gem_update will do exactly that for you. It updates your Gemfile (via bundle update) and finds links for changelogs of updated gems. All you have to do is to copy paste the output to the commit message, and you're done! Obviously, you still have to read changelogs and adapt your code though ;)

Installation and usage

gem install gem_updater
gem_update
<copy paste of output to commit message>

If you prefer to, you can ask gem_update to commit straight away:

gem_update --commit

This will use the generated message as a commit message template, allowing you to edit before commit.

Diff format

By default, diff for your gems will look like the following:

* gem_1 0.1 → 0.2
[changelog](https://github.com/maintainer/gem_1/CHANGELOG.md#02)

* gem_2 3.4.2 → 3.4.3
[changelog](https://github.com/maintainer/gem_2/CHANGELOG.md#343)

You can change it if you like by writing you own template .gem_updater_template.erb in your home directory. Look at default template for an example on how to do it.

Troubleshooting

Changelog not found?

This project relies on the gem’s metadata to find the changelog url. If a changelog was not found, check if the gem’s authors declared its uri in its gemspec, like here.

Contributing

PRs are always welcome! If you wish to contribute, do not hesitate to submit an issue or to open a pull request.

gem_updater's People

Contributors

anthony-robin avatar chourobin avatar dependabot[bot] avatar drakmail avatar mattmenefee avatar maximed avatar oelmekki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gem_updater's Issues

GitHub changelog link anchors no longer found

It appears that the format of GitHub's Changelog has changed slightly such that this line no longer works. I believe it's due to GitHub escaping the word "anchor" when specifying the CSS class on the a tag in more recent versions of its Markdown processor. In my local testing, I found that replacing:

changelog_page.css(%(a.anchor))

with something like this using an XPATH selector:

changelog_page.css(%(//a[contains(@class, "anchor")]))

seemed to have fixed the issue. You may need to update your VCR cassette in order to get a failing test.

HTTPS redirections on github domain

open-uri does not support redirections over https. Since many gems are reported to be on http://github.com, we ensure url is https for github.com, problem is, it does not handle the full domain, and hence, something like http://wiki.github.com will crash.

Looking for a changelog in http://wiki.github.com/wvanbergen/chunky_png
~/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/open-uri.rb:224:in `open_loop': redirection forbidden: http://wiki.github.com/wvanbergen/chunky_png -> https://wiki.github.com/wvanbergen/chunky_png (RuntimeError)
  from ~/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/open-uri.rb:150:in `open_uri'
  from ~/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/open-uri.rb:716:in `open'
  from ~/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/open-uri.rb:30:in `open'
  from ~/.rvm/gems/ruby-2.2.0/gems/gem_updater-0.2.0/lib/gem_updater/source_page_parser.rb:23:in `changelog'
  from ~/.rvm/gems/ruby-2.2.0/gems/gem_updater-0.2.0/lib/gem_updater.rb:29:in `block in update!'
  from ~/.rvm/gems/ruby-2.2.0/gems/gem_updater-0.2.0/lib/gem_updater.rb:25:in `each'
  from ~/.rvm/gems/ruby-2.2.0/gems/gem_updater-0.2.0/lib/gem_updater.rb:25:in `update!'
  from ~/.rvm/gems/ruby-2.2.0/gems/gem_updater-0.2.0/bin/gem_update:9:in `<top (required)>'
  from ~/.rvm/gems/ruby-2.2.0/bin/gem_update:23:in `load'
  from ~/.rvm/gems/ruby-2.2.0/bin/gem_update:23:in `<main>'

Related #13

GitHub changelog links no longer found in certain situations

Over the past few weeks, I've noticed that GitHub changelog links are sometimes not found, though not consistently, which is weird. Upon investigating, I've found an issue with this line.

It seems GitHub has changed their list level markup from:

[aria-labelledby="files"]

to

[aria-labelledby="folders-and-files"]

Additionally, the individual file/folder links no longer have a title attribute, and instead have markup similar to:

<a aria-describedby="item-type-CHANGELOG.md" class="Link--primary" href="/rails/rails/tree/v7.0.8/actioncable/CHANGELOG.md">CHANGELOG.md</a>

I'm not sure what the best what to identify this would be, as your changelog_names array does not contain the file extension. Perhaps something like this would work:

doc.xpath(%(//*[aria-labelledby='folders-and-files']//a[contains(text(), '#{name}')]))

Though in testing that solution, I kept getting a "Failed to load latest commit information." error in place of the file/folder list.

Gem update fails if source_code_uri in rubygems json response is included but has blank value

If the json response from Rubygems includes the source_code_uri key but with a blank value, the method that determines the uri_from_rubygems, specifically this line:

    response[ "source_code_uri" ] || response[ "homepage_uri" ]

will return a blank value, which when passed along to the source_page_parser will result in the following error:

/.rbenv/versions/2.2.3/lib/ruby/2.2.0/open-uri.rb:36:in `open': no implicit conversion of URI::Generic into String (TypeError)
from /.rbenv/versions/2.2.3/lib/ruby/2.2.0/open-uri.rb:36:in `open'
from /.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/gem_updater-0.4.2/lib/gem_updater/source_page_parser.rb:23:in `changelog'
from /.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/gem_updater-0.4.2/lib/gem_updater.rb:53:in `block (2 levels) in fill_changelogs'

The gem that I have installed that I came across this error is parser, which you can see has this issue from its rubygems api response.

So I guess you should make sure that the source_code_uri key is both included and does not have a blank value before falling back to the homepage_uri (where you might want to perform the same check).

Update only specified gems

For some reason once my not want to update his whole gemset. Hence user should be able to list the gems for which he wishes an update.

Something like:

gem_update gem1 gem2

Plans to support other changelog naming conventions?

I've come across a few different changelog naming conventions that are currently not handled:

If you'd like, I can keep a tally of the relative popularity of these alternate naming conventions (and others that I come across), and then perhaps if they are widely used, open a pull request to handle them?

Let me know what you think! Thanks!

undefined method `version' for nil:NilClass (NoMethodError)

gem install gem_updater
gem_update
Updating gems...

... (Updating gems)

Bundle updated!
/Users/jcope/.rvm/gems/ruby-2.1.2@inboxhealth/gems/gem_updater-0.1.0/lib/gem_updater/gem_file.rb:28:in `block in compute_changes': undefined method `version' for nil:NilClass (NoMethodError)
    from /Users/jcope/.rvm/gems/ruby-2.1.2@inboxhealth/gems/gem_updater-0.1.0/lib/gem_updater/gem_file.rb:27:in `compute_changes'
    from /Users/jcope/.rvm/gems/ruby-2.1.2@inboxhealth/gems/gem_updater-0.1.0/lib/gem_updater/gem_file.rb:20:in `update!'
    from /Users/jcope/.rvm/gems/ruby-2.1.2@inboxhealth/gems/gem_updater-0.1.0/lib/gem_updater.rb:17:in `update!'
    from /Users/jcope/.rvm/gems/ruby-2.1.2@inboxhealth/gems/gem_updater-0.1.0/bin/gem_update:9:in `<top (required)>'
    from /Users/jcope/.rvm/gems/ruby-2.1.2@inboxhealth/bin/gem_update:23:in `load'
    from /Users/jcope/.rvm/gems/ruby-2.1.2@inboxhealth/bin/gem_update:23:in `<main>'
    from /Users/jcope/.rvm/gems/ruby-2.1.2@inboxhealth/bin/ruby_executable_hooks:15:in `eval'
    from /Users/jcope/.rvm/gems/ruby-2.1.2@inboxhealth/bin/ruby_executable_hooks:15:in `<main>

Source 'https://rails-assets.org' results in Could not find gem

In gemfile I have this block:

...
source 'https://rails-assets.org' do
  gem 'rails-assets-bacon'
end

bundle update works just fine, but gem_update gives the error:

WARN: Unresolved specs during Gem::Specification.reset:
      mini_portile (~> 0.6.0)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
~/.rvm/gems/ruby-2.2.0/gems/bundler-1.8.3/lib/bundler/resolver.rb:369:in `resolve': Could not find gem 'rails-assets-bacon (>= 0) ruby' in rubygems repository https://rails-assets.org/. (Bundler::GemNotFound)
Source does not contain any versions of 'rails-assets-bacon (>= 0) ruby'
  from ~/.rvm/gems/ruby-2.2.0/gems/bundler-1.8.3/lib/bundler/resolver.rb:167:in `start'
  from ~/.rvm/gems/ruby-2.2.0/gems/bundler-1.8.3/lib/bundler/resolver.rb:129:in `resolve'
  from ~/.rvm/gems/ruby-2.2.0/gems/bundler-1.8.3/lib/bundler/definition.rb:193:in `resolve'
  from ~/.rvm/gems/ruby-2.2.0/gems/bundler-1.8.3/lib/bundler/definition.rb:132:in `specs'
  from ~/.rvm/gems/ruby-2.2.0/gems/gem_updater-0.1.0/lib/gem_updater/gem_file.rb:10:in `initialize'
  from ~/.rvm/gems/ruby-2.2.0/gems/gem_updater-0.1.0/lib/gem_updater.rb:9:in `new'
  from ~/.rvm/gems/ruby-2.2.0/gems/gem_updater-0.1.0/lib/gem_updater.rb:9:in `initialize'
  from ~/.rvm/gems/ruby-2.2.0/gems/gem_updater-0.1.0/bin/gem_update:8:in `new'
  from ~/.rvm/gems/ruby-2.2.0/gems/gem_updater-0.1.0/bin/gem_update:8:in `<top (required)>'
  from ~/.rvm/gems/ruby-2.2.0/bin/gem_update:23:in `load'
  from ~/.rvm/gems/ruby-2.2.0/bin/gem_update:23:in `<main>'

Redirection loop

There is a redirection loop (causing a crash) when updating from pg 0.18.1 to 0.18.2.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.