<commit_before>function _gitcli_get_config() {
	config=`git config --list | grep "${1}"`
	if [ -z "${config}" ]; then
		return 0
	fi
	config=`echo ${config} | cut -d'=' -f 2`
	echo "${config}"
}

function _gitcli_current_branch() {
	branch=`git branch | grep \* | cut -d ' ' -f2`
	echo "${branch}"
}

function _gitcli_create() {

	_gitcli_process "Preparing to create new branch ${newBranch} from ${srcBranch}"

	newBranch=${1}
	srcBranch=${2}

	# first, check if we already have a branch with same name
	if [[ ! -z `git branch --list ${1}` ]]; then
		_gitcli_notice "Branch ${newBranch} already exists"
		return 0
	fi

	_gitcli_fetch_by_branch "${srcBranch}"

	_gitcli_process "Creating new branch ${newBranch} from ${srcBranch}"

	git branch "${newBranch}" ${srcBranch}
}

function _gitcli_checkout() {

	fromBranch=`_gitcli_current_branch`
	toBranch=${1}

	_gitcli_process "${fromBranch} => ${toBranch}"

	# check to see if there are things to be stashed
	hasChanges=`git status -s`
	if [[ ! -z "${hasChanges}" ]]; then
		_gitcli_process "Stashing changes"
		# if has something to stash, stash them and store the commit in config
		git add -A
		git stash
		sha=`git reflog show stash --pretty=format:%H | head -1`
		git config "branch.${fromBranch}.laststash" "${sha}"
	fi

	# store fromBranch as recent branch now and checkout toBranch
	_gitcli_process "Checking out ${toBranch}"
	git config story.mostrecent "${fromBranch}"
	git checkout ${toBranch}

	# if there is last stash for the switched branch, pop that out
	laststash=`_gitcli_get_config "branch.${toBranch}.laststash"`
	if [[ ! -z "${laststash}" ]]; then

		_gitcli_process "Preparing to pop out last stash"

		stashIndex=0
		stashes=`git reflog show stash --pretty=format:%H`
		for stash in ${stashes}; do
			if [[ ${stash} == ${laststash} ]]; then
				break
			fi
			((stashIndex++))
		done

		_gitcli_process "Popping out stash@{${stashIndex}}"

		git stash pop "stash@{${stashIndex}}"
		git config "branch.${toBranch}.laststash" ""
	fi
}

function _gitcli_pull() {

	fromBranch=${1}

	_gitcli_process "Preparing to pull from ${fromBranch}"

	# check to see if there are things to be stashed
	hasChanges=`git status -s`
	if [[ ! -z "${hasChanges}" ]]; then
		_gitcli_error "You have changes. Resolve them first"
		exit 1
	fi

	_gitcli_fetch_all

	_gitcli_process "Pulling from ${fromBranch}"

	remote=`echo ${fromBranch} | cut -d'/' -f 1`
	branch=`echo ${fromBranch} | cut -d'/' -f 2`

	git pull "${remote}" "${branch}"
}

function _gitcli_rebase() {

	branch=${1}

	_gitcli_process "Preparing to rebase on ${branch}"

	# check to see if there are things to be stashed
	hasChanges=`git status -s`
	if [[ ! -z "${hasChanges}" ]]; then
		_gitcli_error "You have changes. Resolve them first"
		exit 1
	fi

	_gitcli_fetch_by_branch "${srcBranch}"

	_gitcli_process "Rebasing on ${branch}"

	git rebase "${branch}"
}

function _gitcli_copy_issue_to_clipboard() {

	branch=`_gitcli_current_branch`
	pattern='^(feature|bugfix)/([0-9]+)(-.*)?'

	if [[ "$branch" =~ $pattern ]]; then
		# if issue id exists in the branch name, copy to clipboard
		issueId=${BASH_REMATCH[2]}
		echo `printf "[DEVJIRA-%s]" ${issueId}` | pbcopy
	else
		_gitcli_notice "Unable to extract issue id from ${branch}"
	fi
}

function _gitcli_open_pr_url() {

	base="${1}"

	_gitcli_process "Preparing to open Pull Request URL with base ${base}"

	# prepare base information
	baseRemote=`echo ${base} | cut -d'/' -f 1`
	baseBranch=`echo ${base} | cut -d'/' -f 2`
	baseUri=`_gitcli_get_config "remote.${baseRemote}.url" | sed 's/git@github.com://' | sed 's/\.git//'`
	baseOwner=`echo ${baseUri} | cut -d'/' -f 1`
	baseRepo=`echo ${baseUri} | cut -d'/' -f 2`
<commit_msg>Modify delete function to account for force delete<commit_after>function _gitcli_get_config() {
	config=`git config --list | grep "${1}"`
	if [ -z "${config}" ]; then
		return 0
	fi
	config=`echo ${config} | cut -d'=' -f 2`
	echo "${config}"
}

function _gitcli_current_branch() {
	branch=`git branch | grep \* | cut -d ' ' -f2`
	echo "${branch}"
}

function _gitcli_create() {

	_gitcli_process "Preparing to create new branch ${newBranch} from ${srcBranch}"

	newBranch=${1}
	srcBranch=${2}

	# first, check if we already have a branch with same name
	if [[ ! -z `git branch --list ${1}` ]]; then
		_gitcli_notice "Branch ${newBranch} already exists"
		return 0
	fi

	_gitcli_fetch_by_branch "${srcBranch}"

	_gitcli_process "Creating new branch ${newBranch} from ${srcBranch}"

	git branch "${newBranch}" ${srcBranch}
}

function _gitcli_checkout() {

	fromBranch=`_gitcli_current_branch`
	toBranch=${1}

	_gitcli_process "${fromBranch} => ${toBranch}"

	# check to see if there are things to be stashed
	hasChanges=`git status -s`
	if [[ ! -z "${hasChanges}" ]]; then
		_gitcli_process "Stashing changes"
		# if has something to stash, stash them and store the commit in config
		git add -A
		git stash
		sha=`git reflog show stash --pretty=format:%H | head -1`
		git config "branch.${fromBranch}.laststash" "${sha}"
	fi

	# store fromBranch as recent branch now and checkout toBranch
	_gitcli_process "Checking out ${toBranch}"
	git config story.mostrecent "${fromBranch}"
	git checkout ${toBranch}

	# if there is last stash for the switched branch, pop that out
	laststash=`_gitcli_get_config "branch.${toBranch}.laststash"`
	if [[ ! -z "${laststash}" ]]; then

		_gitcli_process "Preparing to pop out last stash"

		stashIndex=0
		stashes=`git reflog show stash --pretty=format:%H`
		for stash in ${stashes}; do
			if [[ ${stash} == ${laststash} ]]; then
				break
			fi
			((stashIndex++))
		done

		_gitcli_process "Popping out stash@{${stashIndex}}"

		git stash pop "stash@{${stashIndex}}"
		git config "branch.${toBranch}.laststash" ""
	fi
}

function _gitcli_pull() {

	fromBranch=${1}

	_gitcli_process "Preparing to pull from ${fromBranch}"

	# check to see if there are things to be stashed
	hasChanges=`git status -s`
	if [[ ! -z "${hasChanges}" ]]; then
		_gitcli_error "You have changes. Resolve them first"
		exit 1
	fi

	_gitcli_fetch_all

	_gitcli_process "Pulling from ${fromBranch}"

	remote=`echo ${fromBranch} | cut -d'/' -f 1`
	branch=`echo ${fromBranch} | cut -d'/' -f 2`

	git pull "${remote}" "${branch}"
}

function _gitcli_rebase() {

	branch=${1}

	_gitcli_process "Preparing to rebase on ${branch}"

	# check to see if there are things to be stashed
	hasChanges=`git status -s`
	if [[ ! -z "${hasChanges}" ]]; then
		_gitcli_error "You have changes. Resolve them first"
		exit 1
	fi

	_gitcli_fetch_by_branch "${srcBranch}"

	_gitcli_process "Rebasing on ${branch}"

	git rebase "${branch}"
}

function _gitcli_delete() {

	branch=${1}

	_gitcli_process "Deleting local branch for ${branch}"

	set +e
	result=`git branch -d "${branch}" 2>&1`
	set -e

	if [[ "${result}" =~ 'is not fully merged' ]]; then
		echo
		# if not fully merged, ask user whether to use force
		read -p "This branch is not fully merged. Force delete? (nY): " answer
		answer=${answer:-n}
		echo "answer:" $answer
		case "${answer}" in
			Y)
				_gitcli_process "***FORCE*** Deleting local branch for ${branch}"
				git branch -D "${branch}"
				;;
			*)
				_gitcli_process "Exiting without deleting local branch"
				return 0
				;;
		esac
	fi

	# get name of the remote
	remote=`_gitcli_get_config branch.${branch}.remote`
	if [[ -z "$remote" ]]; then
		_gitcli_process "remote branch was not found for ${branch}"
		return 0
	fi
	if [[ "$remote" != "origin" ]]; then
		_gitcli_process "remote `${remote}` is not origin for ${branch}"
		return 0
	fi

	_gitcli_process "Deleting remote branch for ${branch}"

	git push origin --delete "${branch}"
}

function _gitcli_copy_issue_to_clipboard() {

	branch=`_gitcli_current_branch`
	pattern='^(feature|bugfix)/([0-9]+)(-.*)?'

	if [[ "$branch" =~ $pattern ]]; then
		# if issue id exists in the branch name, copy to clipboard
		issueId=${BASH_REMATCH[2]}
		echo `printf "[DEVJIRA-%s]" ${issueId}` | pbcopy &> /dev/null
	else
		_gitcli_notice "Unable to extract issue id from ${branch}"
	fi

	return 0
}

function _gitcli_open_pr_url() {

	base="${1}"

	_gitcli_process "Preparing to open Pull Request URL with base ${base}"

	# prepare base information
	baseRemote=`echo ${base} | cut -d'/' -f 1`
	baseBranch=`echo ${base} | cut -d'/' -f 2`
	baseUri=`_gitcli_get_config "remote.${baseRemote}.url" | sed 's/git@github.com://' | sed 's/\.git//'`
	baseOwner=`echo ${baseUri} | cut -d'/' -f 1`
	baseRepo=`echo ${baseUri} | cut -d'/' -f 2`

{'fraction_non_alphanumeric': 0.1502944640753828, 'fraction_numerical': 0.006713780918727915, 'mean_word_length': 4.1679853925745585, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6103624', 'n_tokens_mistral': 3226, 'n_tokens_neox': 3022, 'n_words': 935}