Workflow Mangement

Bash: Automate Verbose Error Loggin in Drupal

Turning on verbose error logging in Drupal is an important tool for diagnosing any number of problems. Unless you have the PHP syntax memorized, though, it's a bit of a pain to enable. Even if you keep the $config line commented out in your settings.php file, opening a file editor every time you need to turn it on can also be a pain. Here's a short Bash script that will automatically edit your settings.php file and turn on verbose error logging..

I have a real knack for hitting the WSOD on my localhost--usually when juggling databases and code in between remote and local. As a result, I like to keep verbose error logging commented out in my settings.php. It's generally the last line in the file, somewhere after the $databases array. For privacy reasons I won't screen grab the actual file, but the commented line (for both D8 and D9) should be this:

Bash: A Simple Script for Automating Git Reset

Don't you just hate doing Git Log, sifting through a bunch of commit hashes and then copy-pasting--all so you can reset to an earlier commit? I do--particularly the part where I need to select, copy and then paste the stupid hash. Today was a breaking point, actually. I finally wrote a script that will find the hash I want and pass it to Git Reset for me. My day is finally looking up.

Background

I needed to un-merge a branch today (stakeholders backed out--it happens). This meant reverting my preview branch to a commit just before the merge. This is exactly the kind of thing, I think, that pushes so many devs to graphical Git clients (like, GitKraken, et. al.); doing a reset on the command line is kind of pain. You need to run git log, find the earlier hash for a commit you want to reset to, copy it, and then paste it into a git reset command.

Git: Add, Commit and Push All at Once (Bash Function)

Git is a powerful tool, but sometimes the redundant keystrokes are a pain in the butt. Should you really Add, Commit and Push all in one fell swoop?--No. There are plenty of good reasons not to. Can you? Yes. All it takes is a little scripting with Bash.

Use Case

I love Git. It can sometimes suck the life out of you, though. That may not be the case for everyone. How much time you spend banging your fingers on the command-line kind of depends on your workflow. If you're a front-end dev, for example, and you spend a lot of time tweaking CSS (or SASS, or whatever), a good way to minimize your use of Git is to simply leverage your browser's Developer Tools more efficiently. Another good strategy is to focus on your localhost--reducing the number of pushes you need to make.

Bash: A Simple Script for Checking out New Git Branches

I'm feeling particularly nerdy today and I had a little extra time in my schedule. I recently discussed the utility of Bash Aliases; today, I decided go a step further and put together a Bash Script that allows me to build on that power even more. A Bash Script is basically an Alias on steroids, and if you've had any experience with PHP or JavaScript, there's a lot of overlap. Put on your nerd glasses and let's have a look.

Background - Repetitive Processes w/ Git

You may or may not find this script particularly useful--this post is really about the power of bash scripts to help manage workflow. I do, however, find myself checking out new Git branches somewhat frequently. So, with the extra time in my schedule, I decided to have a little fun and see if I could automate some of that Git workflow with a simple script. Checking out a branch with git isn't a particularly complicated process: git checkout -b <branchname>.

Git: Previewing Multiple Branches in a Single Environment

One of the most difficult aspects of web development has little to do with code: it's called workflow management--and it can mean the difference between hitting Go-Live and adding days or weeks to a project. Things can turn uggly quickly when a finite number of development environments come to odds with exponential requests for code changes. When things get ugly like this, though, Git shines not just as a version control system but as a workflow management tool.

Before I dive hard into the meat of this post, let's get some basic assumptions out of the way--I'm gonna assume that:

Git Error: Unable to Unlink Old <FILE> -- Permission Denied

A branch management error that can seemingly come out of nowhere. Don't worry, there's an easy fix for this one. The key may be in understanding the real power of Sudo in Linux.

TL;DR -- check file permissions; on Linux?--maybe don't use Sudo with Git!

This error is almost definitely a permissions issue. In my case, outlined herein, the problem stemmed from a blatant abuse of sudo. Let's break it all down.

Git Error: Unable to create index.lock

Here's an error I recently came accross in Git when trying to push a commit. If Git is giving you something about being unable to create the index.lock file, it's likely you have a git process running in the background that needs to be resolved before git can move forward.

I was doing some routine updates to Drupal modules today when I got a rather peculiar error: git was unable to create a file called 'index.lock'. I don't know what a lock file is, or why Git even needs to create one, so it caught me by surprise. Reviewing my own terminal, though, and after consulting a thread over at Stack Overflow, It's all clear to me how I ended up where I did. In the end, I fell into the ever enduring trap of not listening to my terminal.