Skip to content

Instantly share code, notes, and snippets.

@simbo1905
Created April 27, 2019 22:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simbo1905/9849529508d45bfce669c94e5838093d to your computer and use it in GitHub Desktop.
Save simbo1905/9849529508d45bfce669c94e5838093d to your computer and use it in GitHub Desktop.
debug git-secret using bashdb and visual studio code
#!/usr/bin/env bash
# https://stackoverflow.com/a/246128/329496
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
# Below we source all the files, except for:
# - other opperating systems (here we assume MacOS aka OSX)
# - main.sh as we will invoke specific methods
# source ${DIR}/src/_utils/_git_secret_tools_freebsd.sh
# source ${DIR}/src/_utils/_git_secret_tools_linux.sh
source ${DIR}/src/_utils/_git_secret_tools_osx.sh
source ${DIR}/src/_utils/_git_secret_tools.sh
# source ${DIR}/src/main.sh
source ${DIR}/src/version.sh
source ${DIR}/src/commands/git_secret_whoknows.sh
source ${DIR}/src/commands/git_secret_usage.sh
source ${DIR}/src/commands/git_secret_init.sh
source ${DIR}/src/commands/git_secret_tell.sh
source ${DIR}/src/commands/git_secret_killperson.sh
source ${DIR}/src/commands/git_secret_hide.sh
source ${DIR}/src/commands/git_secret_changes.sh
source ${DIR}/src/commands/git_secret_reveal.sh
source ${DIR}/src/commands/git_secret_remove.sh
source ${DIR}/src/commands/git_secret_add.sh
source ${DIR}/src/commands/git_secret_cat.sh
source ${DIR}/src/commands/git_secret_list.sh
source ${DIR}/src/commands/git_secret_clean.sh
# change directory to where you test folder is
cd ${DIR}/test_git_checkout
# debug commands by skipping "git secret" instead just use the rest of the commands
tell "initrd@gmail.com"

How To

Install bashdb which you can do from source or get from a package manager. On MacOS you can brew install bashdb.

Install Visual Studio Code and the Bash Debug plugin from the marketplace. See this blog article yet I didn't have to do any upgrades of build from source things worked pretty much out of the box after installing bashdb via Homebrew.

Use the debug.sh script in this gist as the entrypoint to be able to step through code.

{
"version": "0.2.0",
"configurations": [
{
"name": "Bash-Debug (current file)",
"type": "bashdb",
"request": "launch",
"scriptPath": "${file}",
"commandLineArguments": "",
"windows": {
"bashPath": "C:\\Windows\\sysnative\\bash.exe"
},
"linux": {
"bashPath": "bash"
},
"osx": {
"bashPath": "bash"
}
},
{
"name": "Bash-Debug (select script from list of sh files)",
"type": "bashdb",
"request": "launch",
"scriptPath": "${command:SelectScriptName}",
"commandLineArguments": "",
"windows": {
"bashPath": "C:\\Windows\\sysnative\\bash.exe"
},
"linux": {
"bashPath": "bash"
},
"osx": {
"bashPath": "bash"
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment