From 9eae3ed258fdd58d7d2392c64316feda64362f33 Mon Sep 17 00:00:00 2001 From: Billy Brawner Date: Sun, 22 Dec 2019 16:50:02 -0600 Subject: [PATCH] Add pre-script to switch to correct directory for each command Signed-off-by: Billy Brawner --- delete | 2 ++ edit-description | 2 ++ ls | 2 ++ mirror | 2 ++ mirror-github-org | 2 ++ new | 2 ++ notify-jenkins | 2 ++ pre-script | 6 ++++++ 8 files changed, 20 insertions(+) create mode 100644 pre-script diff --git a/delete b/delete index 8be1ecd..9f85e25 100755 --- a/delete +++ b/delete @@ -1,5 +1,7 @@ #!/usr/bin/env sh +source "$(dirname "$0")/pre-script" + if [[ -z "$1" ]]; then echo "Please enter a repository name" exit 1 diff --git a/edit-description b/edit-description index 409af1b..03752ba 100755 --- a/edit-description +++ b/edit-description @@ -1,5 +1,7 @@ #!/usr/bin/env sh +source "$(dirname "$0")/pre-script" + if [[ -z "$1" ]]; then echo "Please enter a repository name" exit 1 diff --git a/ls b/ls index 257407b..119312a 100755 --- a/ls +++ b/ls @@ -1,4 +1,6 @@ #!/usr/bin/env sh +source "$(dirname "$0")/pre-script" + for repo in $(/usr/bin/find -maxdepth 1 -type d -name "*.git"); do /usr/bin/basename $repo .git; done | sort diff --git a/mirror b/mirror index 06306c8..64cb807 100755 --- a/mirror +++ b/mirror @@ -1,5 +1,7 @@ #!/usr/bin/env sh +source "$(dirname "$0")/pre-script" + if [[ -z "$1" ]]; then echo "Please enter a repository URL" exit 1 diff --git a/mirror-github-org b/mirror-github-org index c333584..a322294 100755 --- a/mirror-github-org +++ b/mirror-github-org @@ -1,5 +1,7 @@ #!/usr/bin/env sh +source "$(dirname "$0")/pre-script" + mkdir "$1" ( cd "$1" diff --git a/new b/new index 5221934..a3fb408 100755 --- a/new +++ b/new @@ -1,5 +1,7 @@ #!/usr/bin/env sh +source "$(dirname "$0")/pre-script" + if [[ -z "$1" ]]; then echo "Please enter a repository name" exit 1 diff --git a/notify-jenkins b/notify-jenkins index 1273b4d..e06f6a9 100755 --- a/notify-jenkins +++ b/notify-jenkins @@ -1,5 +1,7 @@ #!/usr/bin/env sh +source "$(dirname "$0")/pre-script" + REPO="$1" if [[ -z "$REPO" ]]; then diff --git a/pre-script b/pre-script new file mode 100644 index 0000000..a975834 --- /dev/null +++ b/pre-script @@ -0,0 +1,6 @@ +#!/usr/bin/env sh + +REPO_DIR=/pub/git + +cd $REPO_DIR +