Skip to content

Commit

Permalink
Fixing precommit
Browse files Browse the repository at this point in the history
Fix shfmt errors

Fix tests to use a cleaner approach

adding --no-interaction to see if that will fix CI

Fix files lint and pre-commit changes

Fix github actions

Fix github actions

more edits on the CI tests enablement

New bats version and tests fix

tryint to fix tests

tryint to fix tests

tryint to fix tests

tryint to fix tests

tryint to fix tests

checking CI work with new flow

checking CI work with new flow

fix enabler status code

check linkeing issues

check linkeing issues

check linkeing issues

check linkeing issues

check linkeing issues

check linkeing issues

check linkeing issues

check linkeing issues

fixing test helpers for tests

fixing test helpers for tests

fixing test helpers for tests

fixing test helpers for tests

fixing test helpers for tests

fixing test helpers for tests

fixing test helpers for tests

fixing test helpers for tests

fixing test helpers for tests

fixing test helpers for tests

fixing test helpers for tests

fixing test helpers for tests

Fix files lint and pre-commit changes

Fix files lint and pre-commit changes

Fix the submodules init
  • Loading branch information
ahmadassaf committed May 17, 2022
1 parent 1157bf9 commit 932b104
Show file tree
Hide file tree
Showing 40 changed files with 522 additions and 691 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
if: startsWith(runner.os, 'macOS')
run: brew install parallel
- name: Test code
shell: 'script -q -e -c "bash {0}"'
run: test/run

lint:
Expand All @@ -42,4 +43,4 @@ jobs:
- name: Install pre-commit
run: python3 -m pip install pre-commit
- name: Run lint
run: pre-commit run --all-files
run: pre-commit run --all-files
2 changes: 1 addition & 1 deletion bin/bats-core
Submodule bats-core updated 240 files
2 changes: 1 addition & 1 deletion bin/bats-file
Submodule bats-file updated 35 files
+28 −0 .github/workflows/tests.yml
+3 −0 .gitignore
+0 −11 .travis.yml
+103 −59 README.md
+36 −0 Vagrantfile
+151 −140 src/file.bash
+11 −7 src/temp.bash
+13 −13 test/50-assert-10-assert_exists.bats
+11 −11 test/50-assert-11-assert_not_exists.bats
+11 −11 test/51-assert-10-assert_file_exists.bats
+11 −11 test/51-assert-11-assert_file_not_exists.bats
+1 −1 test/52-assert-10-assert_file_executable.bats
+0 −0 test/52-assert-11-assert_file_not_executable.bats
+11 −11 test/53-assert-10-assert_link_exists.bats
+10 −10 test/53-assert-11-assert_link_not_exists.bats
+11 −11 test/54-assert-10-assert_character_exists.bats
+10 −10 test/54-assert-11-assert_character_not_exists.bats
+10 −10 test/55-assert-10-assert_block_exists.bats
+10 −10 test/55-assert-11-assert_block_not_exists.bats
+10 −10 test/56-assert-10-assert_fifo_exists.bats
+10 −10 test/56-assert-11-assert_fifo_not_exists.bats
+10 −10 test/57-assert-10-assert_socket_exists.bats
+10 −10 test/57-assert-11-assert_socket_not_exists.bats
+21 −4 test/59-assert-10-assert_file_owner.bats
+20 −2 test/59-assert-11-assert_not_file_owner.bats
+1 −1 test/65-assert-10-assert_symlink_to.bats
+12 −4 test/70-temp-10-temp_make.bats
+45 −6 test/70-temp-11-temp_del.bats
+4 −0 test/fixtures/temp/temp_del-main.bats
+12 −0 test/fixtures/temp/temp_del-setup_file.bats
+12 −0 test/fixtures/temp/temp_del-teardown_file.bats
+4 −0 test/fixtures/temp/temp_make-main.bats
+15 −0 test/fixtures/temp/temp_make-setup_file.bats
+12 −0 test/fixtures/temp/temp_make-teardown_file.bats
+3 −0 test/test_helper.bash
2 changes: 1 addition & 1 deletion bin/bats-support
Binary file added components.zip
Binary file not shown.
23 changes: 14 additions & 9 deletions gaudi_bash.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
#!/usr/bin/env bash
# shellcheck shell=bash
# shellcheck disable=SC1090,SC1091,SC2034
# shellcheck disable=SC1090,SC1091,SC2034,SC2139

# Initialize Bash It
GAUDI_BASH_LOG_PREFIX="CORE"
: "${GAUDI_BASH:=${BASH_SOURCE%/*}}"
: "${GAUDI_BASH_BASHRC:=${BASH_SOURCE[${#BASH_SOURCE[@]} - 1]}}"

case $OSTYPE in
darwin*)
export GAUDI_BASH_PROFILE=".bash_profile"
;;
*)
export GAUDI_BASH_PROFILE=".bashrc"
;;
esac

# Only set $GAUDI_BASH if it's not already set
if [[ -z "$GAUDI_BASH" ]]; then
# Setting $BASH to maintain backwards compatibility
export GAUDI_BASH=$BASH
BASH="$(bash -c 'echo $BASH')"
export BASH

fi

# Load composure first, so we support function metadata and then logging
Expand All @@ -34,14 +46,7 @@ source "${GAUDI_BASH}/lib/appearance.bash"

# handle the case where GAUDI_BASH_RELOAD_LEGACY is set
if ! command -v reload &> /dev/null && [[ -n "$GAUDI_BASH_RELOAD_LEGACY" ]]; then
case $OSTYPE in
darwin*)
alias reload="source \$HOME/.bash_profile"
;;
*)
alias reload="source \$HOME/.bashrc"
;;
esac
alias reload="source \$HOME/${GAUDI_BASH_PROFILE}"
fi

# Disable trap DEBUG on subshells [ref:https://github.com/Bash-it/gaudi-bash/pull/1040]
Expand Down
4 changes: 3 additions & 1 deletion lib/appearance.bash
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,11 @@ export LSCOLORS='cxfxdxgxbxegedabagacad'
GREP_OPTIONS="--color=auto"
alias grep='grep $GREP_OPTIONS'

: "${GAUDI_BASH_ORIGIN:="$GAUDI_BASH"}"

# Load the theme
if [[ -n $GAUDI_BASH_THEME ]]; then
source "$GAUDI_BASH/components/themes/$GAUDI_BASH_THEME/$GAUDI_BASH_THEME.theme.bash"
source "$GAUDI_BASH_ORIGIN/components/themes/$GAUDI_BASH_THEME/$GAUDI_BASH_THEME.theme.bash"
fi

_log_component "$GAUDI_BASH_THEME" "theme"
Expand Down
6 changes: 4 additions & 2 deletions lib/composure.bash
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bash
# shellcheck shell=bash
# shellcheck disable=SC1090
# shellcheck disable=SC1090,1091

source "${GAUDI_BASH}/bin/composure/composure.sh"
: "${GAUDI_BASH_ORIGIN:="$GAUDI_BASH"}"

source "${GAUDI_BASH_ORIGIN}/bin/composure/composure.sh"
24 changes: 2 additions & 22 deletions lib/gaudi-bash.bash
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,7 @@ _gaudi-bash-reload() {
about "reloads the bash profile that corresponds to the correct OS type (.bashrc, .bash_profile)"
group "gaudi-bash:core"

pushd "${GAUDI_BASH}" &> /dev/null || return

case $OSTYPE in
darwin*)
source "$HOME/.bash_profile"
;;
*)
source "$HOME/.bashrc"
;;
esac

popd &> /dev/null || return
[[ -z $GAUDI_TEST_RUNNER ]] && source "${GAUDI_BASH_BASHRC:-${HOME?}/$GAUDI_BASH_PROFILE}"
}

# @function _gaudi-bash-restart
Expand All @@ -67,16 +56,7 @@ function _gaudi-bash-restart() {
about 'Instead of reloading your Bash profile, this command re-runs Bash (using exec)'
group "gaudi-bash:core"

case $OSTYPE in
darwin*)
CONFIG_FILE=".bash_profile"
;;
*)
CONFIG_FILE=".bashrc"
;;
esac

exec "${0#-}" --rcfile "${BASH_IT_BASHRC:-${HOME?}/"${CONFIG_FILE}"}"
exec "${0#-}" --rcfile "${BASH_IT_BASHRC:-${HOME?}/"${GAUDI_BASH_PROFILE}"}"
}

# @function _gaudi-bash-help
Expand Down
1 change: 0 additions & 1 deletion lib/helpers/cache.bash
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ _gaudi-bash-component-cache-add() {
[[ -z $1 ]] && return 1

local file

file="${GAUDI_BASH}/tmp/cache/${1}"
[[ -f ${file} ]] || mkdir -p "${file%/*}"
printf "%s" "${file}"
Expand Down
3 changes: 2 additions & 1 deletion lib/helpers/gaudi-bash.bash → lib/helpers/core.bash
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ _gaudi-bash-describe() {
printf "\n%-20s%-10s%s\n" "${component_type^}" 'Enabled?' ' Description'
printf "%*s\n" "${COLUMNS:-$(tput cols)}" '' | tr ' ' -

file=$(_gaudi-bash-component-cache-add "${component}-enabled")
file=$(_gaudi-bash-component-cache-add "$component-enabled")

[[ "$mode" = "all" ]] && file=${file/-enabled/}

if [[ ! -s "${file}" || -z $(find "${file}" -mmin -300) ]]; then
Expand Down
42 changes: 21 additions & 21 deletions lib/helpers/cursor.bash
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@
# @return success (0) or failure status (1)
# @example ❯ __gaudi-get-cursor-row
function __gaudi-get-cursoer-row() {
local COL
local ROW
IFS=';' read -sdrR -p $'\E[6n' ROW COL
echo "${ROW#*[}"
local COL
local ROW
IFS=';' read -sdrR -p $'\E[6n' ROW COL
echo "${ROW#*[}"
}

# @function __gaudi-get-cursor-column
# @description get the row number of the current cursor position
# @return success (0) or failure status (1)
# @example ❯ __gaudi-get-cursor-column
function __gaudi-get-cursor-column() {
local COL
local ROW
IFS=';' read -sdrR -p $'\E[6n' ROW COL
echo "${COL}"
local COL
local ROW
IFS=';' read -sdrR -p $'\E[6n' ROW COL
echo "${COL}"
}

# @function __gaudi-get-cursor-position
Expand All @@ -30,17 +30,17 @@ function __gaudi-get-cursor-column() {
# @return the position array with array[0] being the cursor's row number and array[1] is the cursor's column number
# @example ❯ __gaudi-get-cursor-position cursor_position
function __gaudi-get-cursor-position() {
export "$1"

exec < /dev/tty
oldstty=$(stty -g)
stty raw -echo min 0
echo -en "\033[6n" > /dev/tty
# tput u7 > /dev/tty # when TERM=xterm (and relatives)
IFS=';' read -r -d R -a pos
stty "$oldstty"
export "$1"

# change from one-based to zero based so they work with: tput cup $row $col
eval "$1[0]=$((${pos[0]:2} - 1))"
eval "$1[1]=$((pos[1] - 1))"
}
exec < /dev/tty
oldstty=$(stty -g)
stty raw -echo min 0
echo -en "\033[6n" > /dev/tty
# tput u7 > /dev/tty # when TERM=xterm (and relatives)
IFS=';' read -r -d R -a pos
stty "$oldstty"

# change from one-based to zero based so they work with: tput cup $row $col
eval "$1[0]=$((${pos[0]:2} - 1))"
eval "$1[1]=$((pos[1] - 1))"
}
4 changes: 3 additions & 1 deletion lib/helpers/disabler.bash
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ _gaudi-bash-disable() {
_gaudi-bash-disable "$file_type" "all"
done
fi
return
return 0
fi

if [[ "$component" = "all" ]]; then
Expand Down Expand Up @@ -65,4 +65,6 @@ _gaudi-bash-disable() {
if [[ -n "$GAUDI_BASH_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE" ]]; then
_gaudi-bash-reload
fi

return 0
}
11 changes: 6 additions & 5 deletions lib/helpers/enabler.bash
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ _gaudi-bash-enable() {
about "enable a gaudi-bash component (plugin, component, alias)"
group "gaudi-bash:core"

mkdir -p "${GAUDI_BASH}/components/enabled"

! __check-function-parameters "$1" && printf "%s\n" "Please enter a valid component to enable" && return 1

local type component load_priority
Expand All @@ -35,7 +37,7 @@ _gaudi-bash-enable() {
_gaudi-bash-enable "$file_type" "all"
done
fi
return
return 0
fi

[[ -z "$component" ]] && printf "${RED}%s${NC}\n" "Please enter a valid $type_singular(s) to enable" && return 1
Expand All @@ -58,17 +60,14 @@ _gaudi-bash-enable() {
enabled_component=$(command compgen -G "${GAUDI_BASH}/components/enabled/[0-9][0-9][0-9]$GAUDI_BASH_LOAD_PRIORITY_SEPARATOR$_component" 2> /dev/null | head -1)
if [[ -n "$enabled_component" ]]; then
printf "${GREEN}$type_singular ${CYAN}$component${NC} %s\n" "is already enabled"
return
return 0
fi

mkdir -p "${GAUDI_BASH}/components/enabled"

# Load the priority from the file if it present there
declare local_file_priority use_load_priority

local_file_priority=$(cat "${GAUDI_BASH}/components/$type/lib/$_component" | metafor priority)
use_load_priority=${local_file_priority:-$load_priority}

ln -s "${GAUDI_BASH}"/components/"$type"/lib/"$_component" "${GAUDI_BASH}/components/enabled/${use_load_priority}${GAUDI_BASH_LOAD_PRIORITY_SEPARATOR}${_component}"
fi

Expand All @@ -79,4 +78,6 @@ _gaudi-bash-enable() {
if [[ -n "$GAUDI_BASH_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE" ]]; then
_gaudi-bash-reload
fi

return 0
}
10 changes: 8 additions & 2 deletions lib/log.bash
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export GAUDI_BASH_LOG_DEBUG_COLOR=${GREEN}
export GAUDI_BASH_LOG_WARNING_COLOR=${YELLOW}
export GAUDI_BASH_LOG_ERROR_COLOR=${RED}

# : "${GAUDI_LOG_DISABLE_COLOR:=0}"

# @function _gaudi-bash-get-component-name-from-path
# @description get a component name from a component path
# @param $1 component path: filesystem path for the component e.g., /Users/ahmadassaf/.gaudi_bash/lib/colors.plugins.bash
Expand Down Expand Up @@ -59,10 +61,14 @@ _log_general() {
local log_type log_color log_prefix

log_type=${2:-GENERAL}
log_color="GAUDI_BASH_LOG_${log_type^^}_COLOR"
log_prefix="${NC}${YELLOW}[${GAUDI_BASH_LOG_PREFIX}]${NC}"

printf "%b\n" "${!log_color} [ ${log_type^^} ] ${log_prefix} $1"
if [[ -n $GAUDI_LOG_DISABLE_COLOR ]]; then
printf "%s\n" " [ ${log_type^^} ] ${log_prefix} $1"
else
log_color=GAUDI_BASH_LOG_${log_type^^}_COLOR
printf "%b\n" "${!log_color} [ ${log_type^^} ] ${log_prefix} $1"
fi
}

# @function _log_debug
Expand Down
6 changes: 4 additions & 2 deletions lib/preexec.bash
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bash
# shellcheck shell=bash
# shellcheck disable=SC1090
# shellcheck disable=SC1090,1091

source "${GAUDI_BASH}/bin/preexec/bash-preexec.sh"
: "${GAUDI_BASH_ORIGIN:="$GAUDI_BASH"}"

source "${GAUDI_BASH_ORIGIN}/bin/preexec/bash-preexec.sh"
5 changes: 2 additions & 3 deletions lib/search.bash
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,9 @@ _gaudi-bash-search-component() {
done

local -a total_matches=($(_array-dedupe "${exact_terms[@]}" "${partial_terms[@]}"))

[[ ${#total_matches} -eq 0 ]] && return 1

unset matches
declare -a matches=()
for match in "${total_matches[@]}"; do
Expand Down Expand Up @@ -227,7 +227,6 @@ _gaudi-bash-search-print-result() {

if [[ "${#matches[@]}" -gt 0 ]]; then


(${GAUDI_BASH_SEARCH_USE_COLOR}) && printf "${YELLOW}%s:${NC}\t" "${component}" || printf "%s:\t" "${component}"

for match in "${matches[@]}"; do
Expand Down
Loading

0 comments on commit 932b104

Please sign in to comment.