My favourite thing about the Chromium code is this enum of cats and all the comments in that file. My second favourite thing is OWNER
files. Guess what this post is about (hint: itâs not about cats NOT EVERYTHING IS ABOUT CATS, OK?)
Edit: In a clear and deliberate conspiracy, the cats have been removed from Chromium. The old new cool thing is pickles, and the new new cool thing is Count Von Counts. Bonus points to @thakis for finding that last one. đ
Why should you care?
Owners in Chromium are people who own an area of code. This can be a small feature (the chrome://settings
page) or a giant area (all of the Cocoa UI). You donât have to be an owner to be successful â you get to be an owner because you want to. This usually means that you have contributed a lot to that particular nugget of code, have acquired a slightly unhealthy obsession for it (symptoms: if youâve whispered âmy preciousâ to a line of code in the last hour, you will make a great code owner one day), and generally care about its well being. I have been trying (unsuccessfully) for years to be an owner of pizza; hit me up if you have any leads.
Owners are gatekeepers of code, and their main responsibility is making sure the code doesnât go to shit. Comments that make sense. No copy pasting, no hacks, no soup for you. None of that âI donât really know how to make this code better so Iâm going to merge it and runâ nonsense. They are the very model of a modern Major-General, they know the kings of England, and they quote the fights historical.
TL; DR: owners wonât let you merge crappy code. Imagine if each of the 2000 Chromium commiters merged a random hack in one of the 7 million lines of code we have. IMAGINE. đ„đ„đ„
What it means for owners
Realtalk: being an owner means that people will send you a lot of code to review, because your blessing (or âLGTMâ) is required for that code to be committed. @sky is an owner of the Windows UI code, and he does something like 500+ reviews a quarter. And also writes code. And helps me out when I (invariably) break the UI. Heâs pretty much the best.
Basically:
- People will ask you general questions when theyâre stuck. Itâs totally fine not to know the answer â youâll probably at least know who to point them at.
- Whenever shit hits the fan and itâs on your turf of code, if no obvious culprit is to be found, you win the lottery and get to fix it. Spoilers: this sometimes means fixing things that you didnât actually break. Currently, Iâm on day 6 of this giant yak shave that I won by fixing a random crash. Regrets, I am them.
- You get to live the dream and be picky about code. Donât like a methodâs name? A particular comment? Think that thereâs a bit of a refactor needed to make this better? You get to ask for it, and guess what: people usually have to listen.
đ Developers trust owners to not be insane. Owners trust developers not to try to commit stuff behind their back. This is why it works. đ
What it means for developers
First, when youâre stuck, you know who to ask questions (an owner!). Second, in order for you to commit any code, you need to get the ownersâ approval for your changes.
Hereâs an example of a code review. I like to explicitly mention which owner should review which file, because one person might own multiple files/areas in a given CL (if youâre a chrome/browser
owner, you own ALL of the things), but might not be required to review all of them.
So, who owns profile_info_cache.cc
? Everyone named in the chrome/browser/profiles/OWNERS
file. On top of that, everyone up the directory tree (so in chrome/browser/OWNERS
) is also an owner. If you stumble on a directory that doesnât have an owners file (for example chrome/browser/ui/cocoa/profiles
), just crawl on up until you find the closest one (in this case, you would add an owner from chrome/browser/ui/cocoa/OWNERS
. This is also useful if you do a fairly innocent refactor that touches a lot of files, like renaming a method. In that case, rather than adding 17 different owners, you can just get one, root owner and run with that.
How YOU can get owner files in your project
If you want to implement owner files for your projects (YAY!), you need to do a couple of things:
- Add some sort of presubmit check so that people canât commit code without getting all their ducks in a row. If you give people a chance to merge code under the radar, they will. So, donât.
- Hereâs the Chromium script. It will probably most likely not work out of the box, but it could be a useful starting point.
- Create OWNER files in all the directories that makes sense. Format them in a way that scripts can read them. Here are all the Chromium ones.
- Owner files can have rules per subdirectory but also per file. For really tedious file changes (like build files), any committer can be an owner using wildcards).
- Make sure the owner files are up to date: when people leave teams, remove them. When people start becoming friendly with an area of code, let them know that ownership is an option.
- Watch how your code gets better over time.