diff options
author | Teddy Wing | 2018-03-18 16:22:07 +0100 |
---|---|---|
committer | Teddy Wing | 2018-03-18 16:22:07 +0100 |
commit | 4132e288ba6af49cf726d71785ec1f2ff9f39270 (patch) | |
tree | da6fe097af5baa9b4855693578fc99d35dfb0fb5 | |
parent | a47bf8ba13440c9691bf002a5bf687175d9c0937 (diff) | |
download | git-branch-list-4132e288ba6af49cf726d71785ec1f2ff9f39270.tar.bz2 |
git-branch-list: Add `clear` command
A new sub-command that clears the entire branch list. This makes it easy
to remove everything when all the branches in the list are stale (e.g.
everything's been merged already).
-rwxr-xr-x | git-branch-list | 7 | ||||
-rw-r--r-- | t/100-clear-clears-all-branches-from-list.t | 36 |
2 files changed, 43 insertions, 0 deletions
diff --git a/git-branch-list b/git-branch-list index 1e8593c..1468bfe 100755 --- a/git-branch-list +++ b/git-branch-list @@ -64,6 +64,10 @@ function drop_branch () { rm "${DATABASE}.bak" } +function clear_branches () { + : > "$DATABASE" +} + function list_branches () { nl "$DATABASE" } @@ -129,6 +133,9 @@ case "$command" in drop) drop_branch "$2" ;; + clear) + clear_branches + ;; "") list_branches diff --git a/t/100-clear-clears-all-branches-from-list.t b/t/100-clear-clears-all-branches-from-list.t new file mode 100644 index 0000000..952d68a --- /dev/null +++ b/t/100-clear-clears-all-branches-from-list.t @@ -0,0 +1,36 @@ +#!/usr/bin/env perl -w + +use strict; + +use Test::More; + +use File::Spec; + +my $BIN = File::Spec->rel2abs('git-branch-list'); + +chdir 't-git-repo' or die $!; + +system('git branch first'); +ok !$?; + +system("$BIN save first"); +ok !$?; + +system('git branch second'); +ok !$?; + +system("$BIN save second"); +ok !$?; + +system("$BIN clear"); +ok !$?; + +my $branch_list = qx($BIN); +is $branch_list, ''; + + +# Teardown +system('git branch -d first second'); + + +done_testing; |