Skip to content

Provide relevant information about to be deleted branches #324

Description

@yarikoptic

I was directed to this repo by claude when I asked for an alternative to my adhoc

bash (or zsh?) script I used for a while
git_brd_merged_HEAD () {
	mode="$1" 
	shift
	branches_regex="${1:-\(gh\|temp\|bm\|bf\|rf\|opt\|bug\|fix\|rm\|pr\|enh\|nf\)[-/]}" 
	branches=(`git branch --merged HEAD | grep -e "^ *$branches_regex" | sed -e 's/^ *//g' `) 
	{
		for branch in ${branches[@]}
		do
			t="$(git describe --contains --match '[v0-9]*.[0-9]*' $branch 2>/dev/null)" 
			rbr=`git config branch.$branch.remote` 
			case $mode in
				(info) echo "Q: Branch: $branch remote: $rbr contained describe: $t"
					continue ;;
				(doit) git_brd "$branch" ;;
				(ask) while true
					do
						echo -n "Q: Branch: $branch remote: $rbr contained describe: $t  Delete [y/n] or gitk [g]? "
						read answer
						if [ "$answer" = "g" ]
						then
							echo
							gitk --select-commit="$branch" HEAD
							continue
						fi
						break
					done
					[ "$answer" = "y" ] && {
						echo
						git_brd "$branch"
					} || {
						echo "skipped $branch"
					} ;;
				(*) echo "Modes are info, doit, ask" >&2
					break ;;
			esac
		done
	} 3<&0
}

and I loved git dmb! well done -- thanks! But it makes me scared to say yes to e.g. deletion of 20+ (or more) branches without extra information on whether that branch was merged or cherry-picked or released in some release already. Also in above shell script of mine I have g to start gitk for that branch@commit so I could visually confirm that it is ok to delete (usually cherry-picked commit nearby).

I think it would have been great that in addition to plain listing of the branches, it showed details on detection (merged or cherry-picked, squashed), # of commits, and in which release that observed 'cherry picked' state was released (that might be tricky unless merged ; I guess). WDYT?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions