I kept trying to write this blog post, but was unsure of what I wanted to say so I kept creating and deleting it. I decided to do a list of things that I learned during the first week or so.
- All code goes through gerrit and has to be reviewed before merging into mediawiki.
- +2 code review and verified means that everything is great and it will be merged.
- You commit code when you have functional changes.
- When your code is in review and a reviewer has made comments and you want to go and fix them, you should amend your changes instead of committing new code. (I committed new code.) Keep amending till reviewer(s) are satisfied and it gets merged.
- Wikimedia is very branch happy. Previously, I never used branches extensively so it was weird for me. I try to make a new branch for every commit I make and name the branch to something meaningful, but sometimes I want to just keep working while my code is being reviewed and everything is dependent on previously committed code. Not sure the workaround yet. (See process below)
- Each branch should only be one commit past master. Ideally.
- In Gerrit, there’s one commit message for a change set. So when you make amends, you should add in what you’ve done to the commit message. This can be done with
git commit --amend. It will just overwrite the commit message. Also useful if you messed up your entire commit message and have to rewrite it. It can be run without changing any code. Make sure you’re in the change set first. (Use
git review -d [change id]first.)
- There are change sets which are new commits and patch sets which are amends to those commits. Some people use them interchangeably.
- You can submit your code in draft mode with
git review -D. It’ll only be visible to reviewers that you add.
Here are some notes that I made for committing code:
For new commits:
*create your branches and make your changes* git diff git status git add <file> git diff --cached git commit git pull origin master git rebase master git review -R
git diff and
git diff --cached are optional, but I like to check what has changed.
git diff shows you what code has changed since the last commit and
git diff --cached is the code that’s going to be going into the next commit.
git review -d [change id] *make your changes* git add git commit --amend git review -R
This is the process of working on code:
git checkout master git checkout -b feature/nextfeature *work on the code* *commit the code* *send it to gerrit* git checkout master git checkout -b feature/anotherfeature
Although for now, a lot of my changes are very dependent on each other so I’ve been waiting for my code to be merged before creating a new branch and working on it.
- The first week or so doesn’t feel like you’re doing much, but you are. I learned all about git and gerrit and how extensions work (which I thought I knew, but really didn’t). I wrote little code, but I was able to correctly submit things.
- Mistakes are for learning. Don’t be too hard on yourself when you make a mistake. I don’t have the ability to screw up Mediawiki. It was through my mistakes that my mentor was able to clarify things that I didn’t know.
- Most of the other interns are on the same boat as me. We’re all learning and making mistakes together. I don’t feel so alone or stupid for not writing code.
- There’s more to this job than just writing code. It’s also about being part of a community. I’ve been asking my mentor for help through #mediawiki instead of PM and other people can chime in. I think he secretly makes me ask in #mediawiki because he’s quite unresponsive in PM. Either way, the consequences are beneficial to me since I can get over my fear of feeling like people think I’m stupid. I hope that I can be active enough to be able to answer newbie questions. :)
- People are more helpful than you think. I didn’t realize how many people would bother answering my silly little questions. I’m not even sure that I should be asking as many questions as I am since it feels like I’m just flooding the chatroom with my problems. But I’m gonna ask them anyways and until someone complains about it, I’m gonna keep doing it. Honestly, I probably am not even asking that many questions.
- Have fun. I don’t know where I got the idea that work is full of dread, but it’s been quickly dispelled over the last week. I don’t feel like I’m doing work because I’m having fun. I think that contributes to the fact that I feel like I haven’t done enough.
I have a notebook beside me to take notes and I write down questions that I have. Periodically, I’ll go back to the questions and I’ll see if I’ve found an answer yet. A lot of the time, I do and I manage to find these questions on my own or find them in passing when someone is explaining something. It’s been quite useful.
I hope that when I look back at these post entries (and future ones) and see what I struggled with and how to solve those problems, I’ll smile and think, yeah, I remember when I didn’t know shit.
Oh! As a side note, there was a meeting for OPW today and unfortunately I missed it. 6 AM was way too early for me. I barely woke up at 8:30 to come to the Wikimedia office. But I read the chat logs and I’m sad that I missed it because it seemed like a great time. Hopefully, I’ll be able to meet everyone and there’s another meeting like this. It’s really nice to have an environment where all the interns can get together and just get all their questions (and frustrations) out.