summaryrefslogtreecommitdiffstats
path: root/framework/src/onos/tools/dev/bin/clean-branches.py
diff options
context:
space:
mode:
authorCNlucius <lukai1@huawei.com>2016-09-13 11:40:12 +0800
committerCNlucius <lukai1@huawei.com>2016-09-13 11:41:53 +0800
commitb731e2f1dd0972409b136aebc7b463dd72c9cfad (patch)
tree5107d7d80c19ad8076c2c97c2b5ef8d1cf3ab903 /framework/src/onos/tools/dev/bin/clean-branches.py
parentee93993458266114c29271a481ef9ce7ce621b2a (diff)
ONOSFW-171
O/S-SFC-ONOS scenario documentation Change-Id: I51ae1cf736ea24ab6680f8edca1b2bf5dd598365 Signed-off-by: CNlucius <lukai1@huawei.com>
Diffstat (limited to 'framework/src/onos/tools/dev/bin/clean-branches.py')
-rwxr-xr-xframework/src/onos/tools/dev/bin/clean-branches.py51
1 files changed, 0 insertions, 51 deletions
diff --git a/framework/src/onos/tools/dev/bin/clean-branches.py b/framework/src/onos/tools/dev/bin/clean-branches.py
deleted file mode 100755
index 3de7cb70..00000000
--- a/framework/src/onos/tools/dev/bin/clean-branches.py
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/usr/bin/env python
-
-from subprocess import check_output
-import sys
-
-def get_merged_branches_by_change_id():
- '''a list of merged branches, by change id excluding support branches and master'''
- raw_changeIds = check_output('git log origin/master | grep -i change-id | awk {\' print $2 \'}', shell=True)
- changeIds = [b.strip() for b in raw_changeIds.split('\n') if b.strip()]
- raw_branches = check_output('git branch -a', shell=True)
- branches = [b.strip() for b in raw_branches.split('\n')
- if b.strip() and not b.startswith('*') and \
- not b.strip().startswith('onos') and not b.strip().startswith('remotes') and b.strip() != 'master']
- to_delete = []
- for branch in branches:
- raw_local_change_ids = check_output('git show %s | grep -i change-id | awk {\' print $2 \'}' % branch, shell=True)
- local_change_ids = [ b.strip() for b in raw_local_change_ids.split('\n') if b.strip() ]
- for local_change_id in local_change_ids:
- if local_change_id in changeIds and branch not in to_delete:
- to_delete.append(branch)
-
- return to_delete
-
-
-def delete_branch(branch):
- return check_output('git branch -D %s' % branch, shell=True).strip()
-
-
-if __name__ == '__main__':
- dry_run = '--confirm' not in sys.argv
- one_by_one = '--one-by-one' in sys.argv
- to_delete = get_merged_branches_by_change_id()
- if len(to_delete) == 0:
- print "Nothing to clean"
- sys.exit(0)
- for branch in to_delete:
- if dry_run:
- print branch
- else:
- if one_by_one:
- print 'Do you want to delete branch %s [y/N]' % branch
- ans = raw_input()
- if ans == 'y' or ans == 'Y':
- print delete_branch(branch)
- else:
- print delete_branch(branch)
-
- if dry_run:
- print '*****************************************************************'
- print 'Did not actually delete anything yet, pass in --confirm to delete'
- print