Using Ruby Software with Local Patches

Unfortunately I don't really know Ruby, nor do expect I will anytime soon. Yet there is software written in that language which I use, and occasionally want to make (trivial) adaptions to.

This blog post is mostly intended as a place to keep notes to myself on how I had changes on a branch in a git repository and rebased them whenever upstream moved. A solution which work well enough with the Ruby ecosystem, if having a setup where all gems are installed for a ruby user with GEM_HOME=~/.ruby set.

After running gem install specific_install the following magic becomes possible:

REPO="local"
URL=`git remote --verbose | \
    sed --silent "s/^${REPO}"'[[:blank:]]*\([^ ]*\) .push.$/\1/p'`
git tag tmp/v`sed --silent 's/.*VERSION = .\(.*\)./\1/p' < \
    lib/*/version.rb`
git push "${REPO}" `git tag --list --points-at HEAD`
gem specific_install --location "${URL}" \
    --branch `git tag --list --points-at HEAD`

The above should be run within a repository with local changes, there must be a remote named local and a version.rb file. Please make sure the clone url for the repository remote named local ends in .git, otherwise specific_install might get very confused and fail.

Versioning of gems appears to follow fairly simple rules, and can not be as specific as e.g. those for debian packages. My pragmatic approach is to simply suffix the existing version number with .1patched, which makes it the newest version when installing but permits that upgrades replace it.

Thanks to olleolleolle for pointing me in the right direction and teaching me about specific_install.


2020-09-20 21:06:24 +0000
Thoughts and feedback may be directed at me using the channel listed on my contact page.

Previous post Next post