Created
August 24, 2013 21:15
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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