Skip to content

Instantly share code, notes, and snippets.

@johnynek
Created August 24, 2013 21:15
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save johnynek/6330451 to your computer and use it in GitHub Desktop.
Save johnynek/6330451 to your computer and use it in GitHub Desktop.
Keeping old branches clean. Run this and it will delete fully merged branches.
#!/bin/sh
exec scala -savecompiled "$0" "$@"
!#
// Get the shell scripting enrichments
import scala.sys.process._
val alwaysKeep = Set("develop", "master")
// Now delete any merged branches"
val branches: String = "git branch".!!
// Have to use augmentString explicitly because the process implicits conflict
augmentString(branches)
.lines
.map { line => if(line(0) == '*') line.drop(1).trim else line.trim }
.filterNot(alwaysKeep)
.foreach { branch =>
("git branch -d %s".format(branch)).!
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment