X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2020-03.git/blobdiff_plain/a211aa1b371c8a4cdc08ed47f3852c4d3081e502..bd4ff344cc3dcaefca30e4ebdca956cd3d92b3b2:/unitproc/bktemp-initGitRepo diff --git a/unitproc/bktemp-initGitRepo b/unitproc/bktemp-initGitRepo index 7a532fa..4575daf 100644 --- a/unitproc/bktemp-initGitRepo +++ b/unitproc/bktemp-initGitRepo @@ -1,6 +1,8 @@ #!/bin/bash # Desc: Initializes a git repository +#==BEGIN Define script parameters== +#===BEGIN Declare local script functions=== yell() { echo "$0: $*" >&2; } #o Yell, Die, Try Three-Fingered Claw technique die() { yell "$*"; exit 111; } #o Ref/Attrib: https://stackoverflow.com/a/25515370 try() { "$@" || die "cannot $*"; } #o @@ -29,7 +31,7 @@ initGitRepo() { # arg2: repoDir # arg3: remoteName # arg4: branchName - # Version: 0.0.4 + # Version: 0.0.6 # Depends: checkURL() 0.0.2, yell(), Bash 5.0.3 # Ref/Attrib: [1]: Test for space-less alphanuemric string. https://unix.stackexchange.com/a/416120 # [2]: Test for argument count. https://stackoverflow.com/q/18568706 @@ -43,6 +45,9 @@ initGitRepo() { if checkURL "$arg1"; then repoURL="$arg1"; else yell "ERROR:Not a valid URL:$arg1"; return 1; fi; + # Passthrough repoDir (it may not exist yet) + repoDir="$arg2"; + # Validate remoteName if [[ "$arg3" =~ ^[[:alnum:]]+$ ]]; then remoteName="$arg3"; else yell "ERROR:Not a valid remote name:$arg3"; return 1; fi; # See [1]. @@ -63,7 +68,6 @@ initGitRepo() { else yell "STATUS:Already a git repository:$repoDir"; git status; git remote -v; - yell "STATUS:Pausing 4 seconds..."; sleep 4; fi; yell "STATUS:Adding $repoURL as remote $remoteName"; git remote add "$remoteName" "$repoURL"; @@ -72,9 +76,12 @@ initGitRepo() { unset repoURL repoDir remoteName branchName; popd || exit 1; #==END create and populate git repository== + yell "================================"; } # Init Git Repository +#===END Declare local script functions=== +#==END Define script parameters== -#==BEGIN test code +#==BEGIN sample code tmpDir=/tmp/"$(date +%Y%m%dT%H%M%S%z)"; mkdir -p "$tmpDir"; pushd "$tmpDir" || exit 1; @@ -87,4 +94,7 @@ initGitRepo "$repoURL" "$repoDir" "$remoteName" "$branchName"; unset repoURL repoDir remoteName branchName; yell "STATUS:Done."; -#==END test code +#==END sample code + +# Author: Steven Baltaktei Sandoval +# License: GPLv3+