Skip to content

Commit 86ebd64

Browse files
Justinmarkchalloner
authored andcommitted
Read config from .git-semver in the base of the repository if it exists. (#29)
1 parent b85b728 commit 86ebd64

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ git semver [help]
133133

134134
Git-semver will check for a configuration file in the following locations (and use the one that exists):
135135

136+
- `$GIT_REPO_ROOT/.git-semver`
136137
- `$XDG_CONFIG_HOME/.git-semver/config`
137138
- `$HOME/.git-semver/config`
138139

git-semver.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,15 @@ readonly DIR_HOME="${HOME}"
340340
# (see http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html)
341341
DIR_CONF="${XDG_CONFIG_HOME:-${HOME}}/.git-semver"
342342

343+
# Set vars
344+
DIR_ROOT="$(git rev-parse --show-toplevel 2> /dev/null)"
345+
343346
# Set (and load) user config
344-
if [ -f "${DIR_CONF}/config" ]
347+
if [ -f "${DIR_ROOT}/.git-semver" ]
348+
then
349+
FILE_CONF="${DIR_ROOT}/.git-semver"
350+
source "${FILE_CONF}"
351+
elif [ -f "${DIR_CONF}/config" ]
345352
then
346353
FILE_CONF="${DIR_CONF}/config"
347354
# shellcheck source=config.example
@@ -351,9 +358,6 @@ else
351358
FILE_CONF="${DIR_HOME}/.git-semver/config"
352359
fi
353360

354-
# Set vars
355-
DIR_ROOT="$(git rev-parse --show-toplevel 2> /dev/null)"
356-
357361
GIT_HASH="$(git rev-parse HEAD 2> /dev/null)"
358362
GIT_BRANCH="$(git rev-parse --abbrev-ref HEAD 2> /dev/null)"
359363

0 commit comments

Comments
 (0)