Hyperlynx

joined 3 years ago
[–] Hyperlynx@aus.social 1 points 2 days ago

@JackbyDev well, it doesn't happen very frequently, it's more of a nice-to have.

It's more of an issue because our product has a lot of totally separate sections, as well as a separate companion app. It's easy enough to work on an issue without ever touching code affected by another, and for whatever reason have two or three issues in progress, each in their own branch.

Say, some task you're blocked on, in the meantime some minor issue from five years ago that nobody really cares about that much but would be nice, and then some other unrelated cleanup task as well.

But, even when I used to work at a place where there was only one single-purpose app, I still worked in topic branches and never ever wanted to actually commit to main (through the mistake was less likely to happen, I grant).

[–] Hyperlynx@aus.social 1 points 2 days ago* (last edited 2 days ago) (2 children)

@JackbyDev yes, friend, you too have entirely missed the point.

I have my branch displayed in my shell, but mistakes happen. And a pre-commit hook that checks what branch I'm on is an excellent way to avoid those mistakes.

I already have a topic branch, likely with a half a dozen odd commits in, which I intended to make my changes in. The hook avoids a mistake made on the one branch I know I pretty much never want to commit to directly.

Yes, I could continue making commits to the wrong branch, and then fix my mistake later. That's noooot the point! I want to commit to the right branch in the first place. Yes, I'm going to need to rebase eventually before I push and put up a merge request - also not the point. The point of the topic branch is that all my work in progress commits are there, I can see the history of what I've tried that has and hasn't worked, and then eventually clean it up with a rebase before actual submission.

All the work neds to go in the topic branch, always, and it already exists because I opened it as soon as I started work on that ticket.

[–] Hyperlynx@aus.social 4 points 4 days ago* (last edited 4 days ago) (4 children)

@Vulwsztyn yeah, "there are multiple ways to fix a mistake" is not the point, dude!

Besides which, yes I do have to rebase if I already have a topic branch for what I'm working on, and didn't pay attention to which branch I'm on.

I almost never want to commit to the main branch, only merge from a topic branch. So that means that having confirmation before committing to it is useful.

[–] Hyperlynx@aus.social 6 points 4 days ago (7 children)

@codeinabox I've got one to ask if I'm sure when I'm committing to anything called master or main. Helps prevent working in the wrong branch.

I don't need to only catch that at the push stage and then have to rebase 🤷🏻‍♂️