repo_bash_completion: move to chromite
This file is managed in chromite now, so drop this copy.
BUG=None
TEST=CQ passes
Change-Id: If9b987b041a239d622524f9a6b698dae6eec3484
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/dev-util/+/2757680
Reviewed-by: Michael Mortensen <mmortensen@google.com>
Tested-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
diff --git a/host/repo_bash_completion b/host/repo_bash_completion
deleted file mode 100644
index f9bf898..0000000
--- a/host/repo_bash_completion
+++ /dev/null
@@ -1,105 +0,0 @@
-# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Programmable completion for some Chromium OS build scripts.
-
-_list_repo_commands() {
- local repo=${COMP_WORDS[0]}
- "${repo}" help --all | grep -E '^ ' | sed 's/ \([^ ]\+\) .\+/\1/'
-}
-
-_list_repo_branches() {
- local repo=${COMP_WORDS[0]}
- "${repo}" branches 2>&1 | grep \| | sed 's/[ *][Pp ] *\([^ ]\+\) .*/\1/'
-}
-
-_list_repo_projects() {
- local repo=${COMP_WORDS[0]}
- "${repo}" list -n
-}
-
-# Complete the repo <command> argument.
-_complete_repo_command() {
- [ ${COMP_CWORD} -eq 1 ] || return 1
- local command=${COMP_WORDS[1]}
- COMPREPLY=($(compgen -W "$(_list_repo_commands)" -- "${command}"))
- return 0
-}
-
-_complete_repo_arg() {
- [ ${COMP_CWORD} -gt 1 ] || return 1
- local command=${COMP_WORDS[1]}
- local current=${COMP_WORDS[COMP_CWORD]}
- if [[ ${command} == "abandon" ]]; then
- if [[ ${COMP_CWORD} -eq 2 ]]; then
- COMPREPLY=($(compgen -W "$(_list_repo_branches)" -- "${current}"))
- else
- COMPREPLY=($(compgen -W "$(_list_repo_projects)" -- "${current}"))
- fi
- return 0
- fi
- if [[ ${command} == "help" ]]; then
- [ ${COMP_CWORD} -eq 2 ] && \
- COMPREPLY=($(compgen -W "$(_list_repo_commands)" -- "${current}"))
- return 0
- fi
- if [[ ${command} == "start" ]]; then
- [ ${COMP_CWORD} -gt 2 ] && \
- COMPREPLY=($(compgen -W "$(_list_repo_projects)" -- "${current}"))
- return 0
- fi
- return 1
-}
-
-# Complete the repo arguments.
-_complete_repo() {
- COMPREPLY=()
- _complete_repo_command && return 0
- _complete_repo_arg && return 0
- return 0
-}
-
-complete -F _complete_repo repo
-
-if [[ -f /usr/share/git/git-prompt.sh ]]; then
- # Path in the cros_sdk chroot
- source /usr/share/git/git-prompt.sh
-elif [[ -f /usr/share/bash-completion/completions/git ]]; then
- # Path on Ubuntu 19.10
- source /usr/share/bash-completion/completions/git
-fi
-
-# Add a way to get the "m" branch from repo easily; used by __git_branch_ps1()
-#
-# Repo seems to maintain a phony 'm/' remote and it always seems to be the name
-# of the manifest branch. This will retrieve it.
-__git_m_branch() {
- local git_dir=$(git rev-parse --git-dir 2> /dev/null)
- if [ -n "${git_dir}" ]; then
- echo $(cd ${git_dir}/refs/remotes/m 2> /dev/null && ls)
- fi
-}
-
-# A "subclass" of __git_ps1 that adds the manifest branch name into the prompt.
-# ...if you're on manifest branch "0.11.257.B" and local branch "lo" and
-# pass " (%s)", we'll output " (0.11.257.B/lo)". Note that we'll never show
-# the manifest branch 'master', since it's so common.
-__git_branch_ps1() {
- local format_str="${1:- (%s)}"
- local m_branch=$(__git_m_branch)
- # Do not print the branch name if it includes 'master'.
- if [[ "${m_branch}" != *master* && -n "${m_branch}" ]]; then
- format_str=$(printf "${format_str}" "${m_branch}/%s")
- fi
- # for subshells, prefix the prompt with the shell nesting level
- local lshlvl=""
- [ ! -z "${SHLVL##*[!0-9]*}" ] && [ ${SHLVL} -gt 1 ] && lshlvl="${SHLVL} "
- __git_ps1 "${lshlvl}${format_str}"
-}
-
-# Prompt functions should not error when in subshells
-export -f __gitdir
-export -f __git_ps1
-export -f __git_m_branch
-export -f __git_branch_ps1