-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make tool installation more user-friendly
We still support 2 types of installations using `install.bash`: 1. using remote git - a production installation which installs latest master branch by default. 2. using local sources - an installation type which is provided for development purposes. It is a part of testing procedure also. By default, a tool is installed into ``${HOME}/.elegant-git` directory. Meanwhile, the installation path can be customized. See `install.bash` for further details. Uninstall process is removed from `install.bash` as it has to be managed separately. New project layout: . ├── bin - production scripts only ├── completions - completions for different shells ├── docs - WEB site with documentation ├── libexec - auxiliary scripts needed for production scripts └── tests - unit tests Also, `run-tests` is working only from a docker environment as it may install 'bad' code into `/usr/local`.
- Loading branch information
Showing
41 changed files
with
125 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
sudo: required | ||
language: bash | ||
services: docker | ||
script: docker run -t --rm -v $PWD:/eg extsoft/elegant-git-ci:1 ./run-tests | ||
script: docker run -t --rm -v $PWD:/eg extsoft/elegant-git-ci:2 ./run-tests | ||
notifications: | ||
email: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,6 @@ RUN apk update && \ | |
gem install pdd | ||
LABEL maintainer="Dmytro Serdiuk <[email protected]>" \ | ||
description="ruby:2.4.1 git:2.13.5 0pdd:0.20.3" \ | ||
version=1 | ||
version=2 | ||
WORKDIR /eg | ||
ENV EG_ENABLE_TESTING true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env bash | ||
# The entry script which should parse its location and run | ||
# original "elegant git". | ||
|
||
# https://stackoverflow.com/a/246128/10418734 | ||
SOURCE="${BASH_SOURCE[0]}" | ||
while [[ -h "$SOURCE" ]]; do | ||
INSTALLATION="$(cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd)" | ||
SOURCE="$(readlink "$SOURCE")" | ||
[[ ${SOURCE} != /* ]] && SOURCE="$INSTALLATION/$SOURCE" | ||
done | ||
INSTALLATION="$(cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd)" | ||
|
||
exec "${INSTALLATION}/../libexec/git-elegant" |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,54 @@ | ||
#!/usr/bin/env bash | ||
# Usage: | ||
# ./install.bash installs to "${HOME}/.elegant-git" from remote git | ||
# ./install.bash /installation/path installs to "/installation/path" from remote git | ||
# ./install.bash /installation/path src installs to "installation/path" from local sources | ||
set -e | ||
|
||
[ -z "$INSTALL_PATH" ] && INSTALL_PATH="$HOME/.git-elegant" | ||
[ -z "$REPO_HOME" ] && REPO_HOME="https://github.com/extsoft/elegant-git.git" | ||
|
||
man() { | ||
echo "Usage: ./install.bash [remote|dev|uninstall]" | ||
echo " - remote - install from GitHub (default)" | ||
echo " - dev - install from local copy" | ||
echo " - uninstall - remove current installation" | ||
echo "" | ||
echo "Configuration:" | ||
echo " INSTALL_PATH=$INSTALL_PATH" | ||
echo " REPO_HOME=$REPO_HOME" | ||
REPO_HOME="https://github.com/extsoft/elegant-git.git" | ||
|
||
copy(){ | ||
local FROM=${1} | ||
local INTO=${2} | ||
install -d -m 755 ${INTO}/{bin,libexec,completions} | ||
install -m 755 ${FROM}/bin/* ${INTO}/bin | ||
install -m 755 ${FROM}/libexec/* ${INTO}/libexec | ||
install -m 644 ${FROM}/completions/* ${INTO}/completions | ||
install -m 644 ${FROM}/LICENSE ${INTO} | ||
install -m 644 ${FROM}/README.md ${INTO} | ||
} | ||
|
||
run() { | ||
echo "$1" | ||
eval "$1" | ||
next-steps() { | ||
local INSTALL_PATH=${1} | ||
local COMPLETION_FILE="${INSTALL_PATH}/completions/git-elegant.bash" | ||
cat <<TEXT >&1 | ||
Please add 3 highlighted lines to your "~/.bashrc" (or "~/.bash_profile"): | ||
-------------------------------------------------------------------------- | ||
# elegant git: ${REPO_HOME} | ||
export PATH=${INSTALL_PATH}/bin:\$PATH | ||
[ -f ${COMPLETION_FILE} ] && . ${COMPLETION_FILE} | ||
-------------------------------------------------------------------------- | ||
Then, please restart the terminal and enjoy the 'elegant git'! | ||
TEXT | ||
} | ||
|
||
install() { | ||
echo "Installing 'elegant git' to $INSTALL_PATH" | ||
run "rm -rfv $INSTALL_PATH" | ||
run "mkdir -p $INSTALL_PATH" | ||
if [ $1 = 'remote' ]; then | ||
run "git clone --depth 1 $REPO_HOME $INSTALL_PATH" | ||
cd "$INSTALL_PATH" | ||
rm -rf .git | ||
elif [ $1 = 'dev' ]; then | ||
cp -rv $(dirname "$0")/* $INSTALL_PATH | ||
main() { | ||
if [[ -n ${1} ]]; then | ||
INSTALL_PATH="${1}" | ||
shift | ||
fi | ||
: ${INSTALL_PATH:="${HOME}/.elegant-git"} | ||
# mode selection | ||
if [[ -z ${1} ]]; then | ||
local CODE="/tmp/elegant-git" | ||
git clone --quiet --depth 1 ${REPO_HOME} ${CODE} | ||
copy ${CODE} ${INSTALL_PATH} | ||
rm -r ${CODE} | ||
else | ||
echo "Unexpected mode: $1" | ||
copy ${0%/*} ${INSTALL_PATH} | ||
fi | ||
|
||
run "mkdir -p $INSTALL_PATH/bin" | ||
run "mkdir -p $INSTALL_PATH/completion" | ||
run "mv $INSTALL_PATH/src/main/git-elegant-completion $INSTALL_PATH/completion" | ||
run "mv $INSTALL_PATH/src/main/git-elegant* $INSTALL_PATH/bin" | ||
|
||
echo "" | ||
echo "Add the following to your .bash_profile to allow:" | ||
echo "# extend 'git' with 'elegant git' commands" | ||
echo "export PATH=$INSTALL_PATH/bin:\$PATH" | ||
echo "#'elegant git' completion" | ||
echo "[ -f $INSTALL_PATH/completion/git-elegant-completion ] && . $INSTALL_PATH/completion/git-elegant-completion" | ||
echo "" | ||
echo "Then please restart the terminal and enjoy the 'elegant git'!" | ||
} | ||
|
||
uninstall() { | ||
echo "Uninstalling 'elegant git' from $INSTALL_PATH" | ||
run "rm -rfv $INSTALL_PATH" | ||
echo "'elegant git' is installed to '${INSTALL_PATH}/bin/git-elegant'." | ||
command -v git-elegant 1>/dev/null 2>&1 || next-steps ${INSTALL_PATH} | ||
} | ||
|
||
case "$1" in | ||
uninstall) uninstall ;; | ||
help) man ;; | ||
dev) uninstall && install dev ;; | ||
*) uninstall && install remote ;; | ||
esac | ||
main $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,18 @@ | ||
#!/bin/bash -e | ||
#!/usr/bin/env bash | ||
# This script is destructive! That's why it will work only if a specific variable is set. | ||
# It's recommended to run it within a docker container only. | ||
set -e | ||
|
||
bats --tap src/test | ||
pdd --source=$(pwd) --verbose --file=/dev/null | ||
if [[ -z $EG_ENABLE_TESTING ]]; then | ||
echo "Testing is disabled!" | ||
exit 1 | ||
fi | ||
|
||
fail() { | ||
echo $@ | ||
exit 1 | ||
} | ||
|
||
bats --tap tests || fail "Unit tests are failed." | ||
./install.bash /usr/local src && git elegant help || fail "Installation test is failed." | ||
pdd --source=$(pwd) --verbose --file=/dev/null || fail "Unreadable todo is identified." |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.