I’m lazy. Talk to anyone who programs and they will tell you the same (or they will lie to you). Programming is the art of lazy people who want to not do things over and over. I look at almost every task I do on the computer and think “could I automate this?” because: lazy. It’s why I am learning regular expressions (a way of searching through text) and why I love bash. Warning this is going to get technical…
So this site is version controlled with git. I track all the changes to the site’s code into a repository on github.com. This is awesome because it allows me to share the code and collaborate with others. However there is one major issue, I want to allow my collaborators the autonomy to add their own plugins to the site and update those plugins without my help.
This presents a problem with version control, when a plugin is added or updated through the website files are added and changed on the server. This means that the version control must be updated. With git that looks something like this:
$ git add wp-content/plugins/alc-tuition-slider
$ git commit -m "updated plugin alc-tuition-slider"
Now I could add all the updated plugins at once, but then I couldn’t roll back plugin updates that cause problems. Git stores each “commit” as a single record. So each change that is committed to that log can also be UNcommitted! This means, however, that when a bunch of plugins are updated I have to go into the server and add each plugin and commit them! Writing a commit message for each one. I’ve done this, for months, every time plugins get updated. Just look at the commit log, I was doing that all by hand. I needed a lazier way. So I wrote a script (it was a frustrating process) but I got it!
You can look at the script here. I wrote it in bash, it’s a function that pulls the most recent code, then checks for code changes in the plugin folder. It loops over each change and adds the plugin to a list, then goes through that list and add’s the plugin and commits it one by one.
It does all my work for me! Now when there’s updates I just have to login and run a script then go back to being a lazy bum!