Posted by matijs
24/05/2025 at 08h49
You want to work on some project, but they use a branch named dog
and you
want to use cat
instead. So you go:
git checkout dog
git switch -c cat
git branch --set-upstream-to=origin/dog
git branch -d dog
Your local branch is now cat
and it tracks dog
. Whenever your dog-loving
friends push their work, you can just use
git pull --rebase
and your cat
branch will be updated with the new commits in origin/dog
.
Now, the time comes to push your own work, and you go:
git push
Now, however, something perhaps unexpected happens. Instead of your commits
getting pushed to dog
, a new branch cat
is created in the remote
repository. That’s not what you wanted!
To make this work properly, you have to change git’s configuration:
git config set --global push.default upstream
From the git config
man page, this setting will:
push the current branch back to the branch whose changes are usually
integrated into the current branch
In other words this pushes to the branch set with --set-upstream-to
, which
normally only affects pulling.
Now git push
will push your cat
branch to the remote origin/dog
branch,
allowing cat people and dog people to work together peacefully.
PS: With this push setting, pushing a branch without an equivalent upstream
will fail. To instead make git push
create an upstream branch for you, set:
git config set --global push.autoSetupRemote true
Tags
git, TIL
no comments
no trackbacks
Posted by matijs
26/09/2024 at 16h54
I think a good process is something like this:
- Add the standard library gems to the dependencies so the warnings go away. For gem projects I think it’s fine to put them in the development dependencies because the published gems don’t need these dependencies right now
- Figure out which gems load the standard library gems
- File bug reports for those gems to make them add the standard library gems as dependencies
- Wait for those gems to be updated and then update the dependencies on those gems in my project
- Remove the standard library gems from the dependencies again
To be honest, I think I have only ever gotten as far as point 2.
Tags
maintenance, programming, ruby
no comments
no trackbacks
Posted by matijs
07/04/2022 at 12h01
Remember that blog comes from weblog, and (I believe) originally was supposed to (also) mean a log of interesting stuff one encountered around the web, as opposed to a collection of largish articles about a specific subject. Remember that before Twitter, the small posts were also posted on blogs.
Let’s do some old-school blogging and post small stuff about random subjects, mostly links.
Tags
meta
no comments
no trackbacks
Posted by matijs
11/12/2021 at 09h26
AsciiDoc is nice because a lot
is possible. However, there are a lot of surprising edge cases that make it
less great as an easy to read and write documentation format.
-
Some list markers support nesting, others do not
If you use a dash (-
) as a list marker, that works fine until you want to
create nested lists. Then, it turns out you should be using *
.
-
Outdenting lists has very weird syntax.
To outdent a list, you have to add a number of empty lines equal to the
number of outdents plus one, followed by an empty line with a +
. This is
too specific for a human-readable format.
-
Escaping only works where it is needed.
Wherever an asterisk leads to bolding, you can escape it using a \
to create a literal
asterisk. However, when the use of an asterisk does not lead to bolding, adding the \
will just lead to a literal \
in the output. Predicting where this will
happen is tricky so you have to constantly look at the actual output.
Tags
asciidoc, processing, software, text
no comments
no trackbacks
Posted by matijs
10/10/2020 at 14h32
For a long time, part of my weekend routine has been updating the dependencies of all my open source Ruby projects. I had set up some tooling to automatically run bundle outdated
on all my project directories and make a nice report. For good measure, it would also run RuboCop and tell me if any work was needed on that front.
I would then go through the list of needed work, adjust the dependencies (using KeepUp where possible), activate new RuboCop cops, fix new RuboCop offenses, create pull requests, wait for builds to be done and then merge. There actually was a certain satisfaction in keeping things up-to-date, keeping things neat.
A few weeks ago, I’d had enough. The process of keeping things up-to-date was starting to become tedious, and it was keeping me from writing actual new software. Having had good experience at work with Dependabot I decided to automate dependency updates for all my open source repo’s.
After some experimenting I made the following changes to my repositories:
-
I added a separate named RuboCop job as part of each repository’s Travis CI configuration. To do this requires using the jobs
key instead of rvm
, like so:
jobs:
include:
- rvm: 2.5
- rvm: 2.6
- rvm: 2.7
- rvm: 2.7
name: "RuboCop"
script: bundle exec rubocop
-
I configured GitHub’s native version of Dependabot to create pull requests daily, using a file .github/dependabot.yml
in each repository:
version: 2
updates:
- package-ecosystem: bundler
directory: "/"
schedule:
interval: daily
time: "04:23"
open-pull-requests-limit: 10
All this means is that the manual part has been reduced to just checking that the builds are green for the pull requests produced by Dependabot, and potentially any new issues found by newer versions of RuboCop.
no comments
no trackbacks
Posted by matijs
29/03/2020 at 08h38
Actually, problems only get solved because people roll up their sleeves and do shit, and government is the collective coordinating apparatus that helps us know what shit needs to get done and who needs to do it.
Current Affairs, Everything has changed overnight, via @AnnieGal@mastodon.social
no comments
no trackbacks
Posted by matijs
20/03/2020 at 13h08
Automating away your library release process because you find it boring and tedious is the worst thing you can do. People rely on your releases to be meaningful, have meaningful version numbers, and meaningful release notes. Yes, these take time. But your releases are when your users are reminded that you exist. At other times, your library is just quietly doing its thing. Releases are when your users take notice. They want to read your change log, look at the version number to see if they need to pay attention. You’re in the spotlight. This is your performance. Give your releases some love.
Tags
development, software
no comments
no trackbacks
Posted by matijs
31/12/2018 at 15h46
- Your next release should nearly always come from the
master
branch.
- When updating your feature branch, prefer
git rebase master
over git merge master
.
- When merging your feature into
master
, prefer merge bubbles over squash merges and fast-forwards.
-
bundle exec rake
should run your tests.
- You still should not check in
Gemfile.lock
.
- Use RuboCop. Running just
rubocop
should do the right thing. If you need a specific version, add it to the Gemfile. In that case, bundle exec rubocop
should do the right thing.
Tags
development, opinions, ruby
no comments
no trackbacks
Posted by matijs
20/09/2018 at 09h03
I happened upon
this comment.
But more important, it just doesn’t work sensibly to explain why many people
decline modest bets (e.g. that someone not on the brink of starvation would
decline a 50/50 lose $100 vs gain $110) bet.
You can look at this bet in two ways. The first is the single bet. Then, you
can think about how bad you feel about losing $100, versus how good you feel
about gaining $110.
The second way is as a repeated bet. And I think this is how people do think
about it: If I bet yesterday, why not bet today? Or, I lost yesterday, I need
to bet again today to ‘make up for it’.
Emotions aside, the reason given that the bet is a good one, is that in the
long run the better will come out ahead. But how long is the long run?
Let’s fire up irb
. (I’ve reformatted the lines a bit to fit in an article layout.)
>> def bet; rand < 0.5 ? -100 : 110; end
>> count = 0; sum = 0; while sum < 1; count+= 1; sum += bet; end; [count, sum]
=> [81, 90] # Oops!
>> min = 0; count = 0; sum = 0; \
> while sum < 1; count+= 1; sum += bet; min = sum if sum < min; end; \
> [count, min, sum]
=> [35, -530, 70] # OOPS!
Maybe you can spare $100, but can you spare $530? (Not to mention the fact that
many people can’t spare $100.).
Or even $1340, leading to a $50 win after 136 bets?
=> [136, -1340, 50]
What are the chances of a repeated bet ruining you before you gain anything at all?
>> def compound_bet; min = 0; count = 0; sum = 0; \
> while sum < 1; count+= 1; sum += bet; min = sum if sum < min; end; \
> [count, min, sum]; end
>> def killer_bet(threshold); count, min, sum = compound_bet; min < -threshold; end
>> def killer_chance(threshold); 100000.times.select { killer_bet(threshold) }.count / 1000.0; end
>> killer_chance(500) #=> 8.017
>> killer_chance(1000) #=> 3.532
A betting scheme with a 3.5% chance of losing $1000 doesn’t sound so good…
(The commenter goes on to point to an article that actually doesn’t make the
claim that the given debt is a ‘modest debt’, and seems far more interesting
than that.)
Tags
programming
no comments
no trackbacks
Posted by matijs
25/07/2018 at 06h59
I started reading this, and came upon this line:
Many people claim to know how SemVer works, but have never read the specification.
And I thought: Yes! This is exactly the problem. Everyone talks about SemVer, but no-one reads the specification, so the discussions don’t make sense. Finally, someone is going to Make Things Clear!
…
And then I read this:
Note: Stop trying to justify your refactoring with the “public but internal” argument. If the language spec says it’s public, it’s public. Your intentions have nothing to do with it.
What!? This person complains about people not reading the specifications, and then proceeds to contradict the very first article of the SemVer specification? Here it is (highlight mine):
Software using Semantic Versioning MUST declare a public API. This API could be declared in the code itself or exist strictly in documentation. However it is done, it should be precise and comprehensive.
Whether the language spec says it’s public has little to do with it.
Now, there’s a discussion going on on Hacker News about this article, and clearly I’m not the only one bothered by the quote above, but the commenters are focused on whether languages allow you to control what part of your API is exposed, rather than what the SemVer spec actually says.
No-one understands SemVer.
Tags
annoyance, programming, SemVer
no comments
no trackbacks