From 04ec91484083417a93c91318e08986706e82c006 Mon Sep 17 00:00:00 2001 From: Dmytro Serdiuk Date: Sat, 7 Dec 2019 22:30:15 +0200 Subject: [PATCH] Prevent "not a git repository" error during initiating a repository Prior to the execution of any command, Elegant Git seeks the workflow files. And in order to solve them from any position in a working tree, it uses Git command for resolving a path to the root of the repository. In the case, if `init-repository` or `clone-repository` is executed, Git will raise an error: "not a git repository (or any of the parent directories): .git." This happens as there is no `.git` directory at the moment of the command execution. Now, for both commands (`init-repository` and `clone-repository`), Git command for the path evaluation won't be executed. This does not affect the logic of the workflow execution but prevents the error. --- libexec/git-elegant | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libexec/git-elegant b/libexec/git-elegant index 215a558..7a418d7 100755 --- a/libexec/git-elegant +++ b/libexec/git-elegant @@ -113,7 +113,9 @@ MESSAGE --run-workflow(){ local type=${1} local command=${2} - local prefix=$(git rev-parse --show-cdup) + if [[ ! "init-repository clone-repository" =~ ${command} ]]; then + local prefix=$(git rev-parse --show-cdup) + fi --run-file "${prefix}.git/.workflows/${command}-${type}" --run-file "${prefix}.workflows/${command}-${type}" }