DEV Community

Discussion on: Invest in building custom tools

Collapse
 
kenbellows profile image
Ken Bellows

This may be a bit off topic, since the question is more about actual tooling that's worked into the dev process and maintained by the team, but this makes me think about the tiny automation scripts I write to avoid having to manually perform tedious tasks.

I'm always doing this sort of thing at work: writing userscripts to fix time-wasting bugs in corporate web applications, scripting tasks I don't want to do (or do too often), and trying to share this stuff around as much as I can. I might occasionally spend too much time on it... but I learn stuff, others sometimes benefit from it (though the majority of what I write is only ever used by me), and it's fun 😁. It's that classic hacker mindset of "why do it by hand when I can write a script to do it for me?". Even when writing the script takes longer, it's more enjoyable, and then if it ever comes up again, boom, already got the script!

For instance, last Tuesday my team lead noticed that our remote git repo was becoming clogged with old, merged branches that hadn't been deleted. He asked each of us devs to go through the branches we had created, check whether the associated tickets were closed, and clean them up. I had like 40 branches to check and clean up. I could have manually checked each and banged the git commands into the keyboard one at a time, and it probably would have taken like twenty minutes. But I decided to script the whole thing. It took me at least 20 minutes to figure that out, probably more like 30 (mostly because of checking the ticket statuses), but now I've got it done, and I have a feeling that this will come up again in a few months. And I may be able to share it around if someone else wants it.

But even if I never look at it again, it was still good practice, and I learned some neat things about our ticketing system, git commands, and xargs that will be useful anyway. And I mean, come on, that manual process would have been super boring. This was way more fun 😎💻

Collapse
 
brpaz profile image
Bruno Paz

I had exactly the same issue with old branches in a project I worked on.
It was maybe two years of development without deleting most of the merged branches.

A Dev also build a script similar to yours ;)

Collapse
 
rhymes profile image
rhymes • Edited

And I may be able to share it around if someone else wants it.

Hello, I'm someone :D

Collapse
 
kenbellows profile image
Ken Bellows

Ha, I was more referring to my teammates, but I can share some of it. The bit involving checking branches against our ticketing system (aka the interesting part) is very tailored and wouldn't be useful outside of my office, but the bit that actually deleted the branches is just a little git + xargs:

cat branches_to_delete | xargs -L1 git push origin --delete