Skip to content

Commit

Permalink
[DP-130] dod engineer can onboard tng (#12)
Browse files Browse the repository at this point in the history
* improve comments and fix asdf step

* added pre-commit and better docs to git step

* correctly detect tool repos not cloned

* check for augment sourcing in shell test

* Bump version to 0.1.3

Co-authored-by: SteveRuble <SteveRuble@@users.noreply.github.com>
  • Loading branch information
SteveRuble and SteveRuble authored Feb 7, 2022
1 parent 2e278eb commit 5c86f81
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 19 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.2
0.1.3
2 changes: 1 addition & 1 deletion formula/ih-core.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class IhCore < Formula
VERSION="0.1.2"
VERSION="0.1.3"
desc "Brew formula for installing core tools used at Included Health engineering."
homepage "https://github.com/ConsultingMD/homebrew-ih-public"
license "CC BY-NC-ND 4.0"
Expand Down
2 changes: 1 addition & 1 deletion lib/core/asdf/step.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function ih::setup::core.asdf::install() {
ih::log::info "Cloning asdf into $HOME/.asdf"
git clone https://github.com/asdf-vm/asdf.git "$HOME"/.asdf --branch v0.9.0
# shellcheck disable=SC1091
. "$HOME/.asdf/completions/asdf.bash"
. "$HOME/.asdf/asdf.sh"
fi

local CURRENT_PLUGINS
Expand Down
39 changes: 29 additions & 10 deletions lib/core/git/step.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ function ih::setup::core.git::help() {
echo "Configure git settings
This step will:
- update your global git config to use some good defaults
- create $GR_HOME if it doesn't exist
- create a default global .gitignore if one doesn't exist"
- Update your global git config to use some good defaults
This will not overwrite any existing settings that you have set.
- Create $GR_HOME if it doesn't exist.
- Create a default global .gitignore if one doesn't exist.
- Set up pre-commit to install automatically when repos are cloned."

}

function ih::setup::core.git::test() {
Expand All @@ -32,22 +35,38 @@ function ih::setup::core.git::install() {
# Profile must be valid before we can setup git
ih::setup::core.shell::private::configure-profile

git config --global user.name "${GITHUB_USER}"
git config --global user.email "${GITHUB_EMAIL_ADDRESS}"
git config --global color.ui true
git config --global core.excludesfile "${HOME}/.gitignore_global"
git config --global push.default simple
ih::setup::core.git::private::set-if-unset "user.name" "${GITHUB_USER}"
ih::setup::core.git::private::set-if-unset "user.email" "${GITHUB_EMAIL_ADDRESS}"
ih::setup::core.git::private::set-if-unset "color.ui" "true"
ih::setup::core.git::private::set-if-unset "core.excludesfile" "${HOME}/.gitignore_global"
ih::setup::core.git::private::set-if-unset "push.default" "simple"

# make git use ssh for everything
git config --global url.ssh://git@github.com/.insteadOf https://github.com/

# set up pre-commit to automatically be set up for all cloned repos,
# if the user doesn't have a templateDir already
if git config --global init.templateDir; then
ih::log::warn "Detected existing templateDir, not setting up pre-commit auto-enable."
else
local GIT_TEMPLATE_DIR="${IH_DIR}/git-template"
mkdir "$GIT_TEMPLATE_DIR" 2>/dev/null || :
git config --global init.templateDir "$GIT_TEMPLATE_DIR"
pre-commit init-templatedir "$GIT_TEMPLATE_DIR"
fi

# Make sure the desired src directory exists if GR_HOME is declared
[[ -n ${GR_HOME} ]] && mkdir -p "${GR_HOME}"

# Copy the gitignore template into global if there isn't already a global.
cp -n "${IH_CORE_LIB_DIR}/core/git/gitignore" "${HOME}/.gitignore_global" || :

echo "Updated git global config as follows:"
ih::log::info "Updated git global config as follows:"
git -P config --global --list
echo ""
}

echo "Git configuration completed."
# sets global config setting $1 to value $2 if it is not currently set
function ih::setup::core.git::private::set-if-unset() {
git config --global "$1" || git config --global "$1" "$2"
}
10 changes: 10 additions & 0 deletions lib/core/shell/step.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ function ih::setup::core.shell::test() {
return 1
fi

if ! grep -q -e "augment.sh" ~/.bashrc; then
ih::log::debug "Augment not sourced in .bashrc"
return 1
fi

if ! grep -q -e "augment.sh" ~/.zshrc; then
ih::log::debug "Augment not sourced in .zshrc"
return 1
fi

local DEFAULT_SRC_DIR="${IH_CORE_LIB_DIR}/core/shell/default"
local DEFAULT_DST_DIR="${IH_DIR}/default"

Expand Down
4 changes: 3 additions & 1 deletion lib/core/ssh/step.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ function ih::setup::core.ssh::install() {
ssh-add -K "$HOME/.ssh/id_rsa"
else
ih::log::warn "Uh-oh. you have an existing ssh key, but it doesn't appear to be a 4k RSA key."
if ih::ask::confirm "I want to back up your existing key and create a new one."; then
if ih::ask::confirm "I want to back up your existing key and create a new one.
If you have already configured GitHub to trust this key, and it has a password, you
can say no. Otherwise, you should say yes and a new key will be created."; then
mv "$HOME"/.ssh/id_rsa "$HOME"/.ssh/id_rsa.old
mv "$HOME"/.ssh/id_rsa.pub "$HOME"/.ssh/id_rsa.pub.old

Expand Down
5 changes: 0 additions & 5 deletions lib/core/toolrepos/step.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ function ih::setup::core.toolrepos::help() {
}

function ih::setup::core.toolrepos::test() {

ih::setup::core.toolrepos::test-or-install "test"

return 0
}

function ih::setup::core.toolrepos::deps() {
Expand All @@ -24,9 +21,7 @@ function ih::setup::core.toolrepos::deps() {
}

function ih::setup::core.toolrepos::install() {

ih::setup::core.toolrepos::test-or-install "install"

}

# If $1 is "test", this will check if install is needed and return 1 if it is.
Expand Down

0 comments on commit 5c86f81

Please sign in to comment.