Skip to content

Commit 73bd66e

Browse files
benpboltonsamrocketman
authored andcommitted
consolidate user options and deps inclusion (#104)
* consolidate user options and deps inclusion moving the per-script inclusion to a single location * add trailing newline
1 parent 900e508 commit 73bd66e

File tree

6 files changed

+16
-35
lines changed

6 files changed

+16
-35
lines changed

add_mirror.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,7 @@ set -e
1010

1111
#Include all user options and dependencies
1212
git_mirrors_dir="${0%/*}"
13-
[ -f "${git_mirrors_dir}/config.sh" ] && . "${git_mirrors_dir}/config.sh"
14-
. "${git_mirrors_dir}/lib/VERSION"
15-
. "${git_mirrors_dir}/lib/functions.sh"
16-
if [ ! -f "${git_mirrors_dir}/config.sh" ];then
17-
red_echo "config.sh missing! Copy and customize from config.sh.SAMPLE. Aborting." 1>&2
18-
exit 1
19-
fi
13+
source ${git_mirrors_dir}/includes.sh
2014

2115
#check if api version is set
2216
[ -z $gitlab_api_version ] && gitlab_api_version=4

delete_mirror.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,7 @@ set -e
88

99
#Include all user options and dependencies
1010
git_mirrors_dir="${0%/*}"
11-
[ -f "${git_mirrors_dir}/config.sh" ] && . "${git_mirrors_dir}/config.sh"
12-
. "${git_mirrors_dir}/lib/VERSION"
13-
. "${git_mirrors_dir}/lib/functions.sh"
14-
if [ ! -f "${git_mirrors_dir}/config.sh" ];then
15-
red_echo "config.sh missing! Copy and customize from config.sh.SAMPLE. Aborting." 1>&2
16-
exit 1
17-
fi
11+
source ${git_mirrors_dir}/includes.sh
1812

1913
#check if api version is set
2014
[ -z $gitlab_api_version ] && gitlab_api_version=4

git-mirrors.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,7 @@
55

66
#Include all user options and dependencies
77
git_mirrors_dir="${0%/*}"
8-
[ -f "${git_mirrors_dir}/config.sh" ] && . "${git_mirrors_dir}/config.sh"
9-
. "${git_mirrors_dir}/lib/VERSION"
10-
. "${git_mirrors_dir}/lib/functions.sh"
11-
if [ ! -f "${git_mirrors_dir}/config.sh" ];then
12-
red_echo "config.sh missing! Copy and customize from config.sh.SAMPLE. Aborting." 1>&2
13-
exit 1
14-
fi
8+
source ${git_mirrors_dir}/includes.sh
159

1610
cd "${git_mirrors_dir}"
1711

includes.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash -e
2+
3+
#Include all user options and dependencies
4+
git_mirrors_dir="${0%/*}"
5+
[ -f "${git_mirrors_dir}/config.sh" ] && . "${git_mirrors_dir}/config.sh"
6+
. "${git_mirrors_dir}/lib/VERSION"
7+
. "${git_mirrors_dir}/lib/functions.sh"
8+
if [ ! -f "${git_mirrors_dir}/config.sh" ];then
9+
red_echo "config.sh missing! Copy and customize from config.sh.SAMPLE. Aborting." 1>&2
10+
exit 1
11+
fi

ls-mirrors.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,7 @@ set -e
1010

1111
#Include all user options and dependencies
1212
git_mirrors_dir="${0%/*}"
13-
[ -f "${git_mirrors_dir}/config.sh" ] && . "${git_mirrors_dir}/config.sh"
14-
. "${git_mirrors_dir}/lib/VERSION"
15-
. "${git_mirrors_dir}/lib/functions.sh"
16-
if [ ! -f "${git_mirrors_dir}/config.sh" ];then
17-
red_echo "config.sh missing! Copy and customize from config.sh.SAMPLE. Aborting." 1>&2
18-
exit 1
19-
fi
13+
source ${git_mirrors_dir}/includes.sh
2014

2115
PROGNAME="${0##*/}"
2216
PROGVERSION="${VERSION}"

update_mirror.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,7 @@ set -e
1010

1111
#Include all user options and dependencies
1212
git_mirrors_dir="${0%/*}"
13-
[ -f "${git_mirrors_dir}/config.sh" ] && . "${git_mirrors_dir}/config.sh"
14-
. "${git_mirrors_dir}/lib/VERSION"
15-
. "${git_mirrors_dir}/lib/functions.sh"
16-
if [ ! -f "${git_mirrors_dir}/config.sh" ];then
17-
red_echo "config.sh missing! Copy and customize from config.sh.SAMPLE. Aborting." 1>&2
18-
exit 1
19-
fi
13+
source ${git_mirrors_dir}/includes.sh
2014

2115
#sane update defaults that are backwards compatible
2216
force_update="${force_update:-false}"

0 commit comments

Comments
 (0)