fix(bktemp-updateloopPI):Add integral sum spike dampener
[BK-2020-03.git] / unitproc / bktemp-initGitRepo
index a222ad39d73661fca21d73d827cc093c8f2bb8b7..911a63c3bde38c621cb2ed7a47ee6f992cc891e9 100644 (file)
@@ -2,8 +2,6 @@
 # Desc: Initializes a git repository
 
 #==BEGIN Define script parameters==
-#==END 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
@@ -33,11 +31,15 @@ initGitRepo() {
     #        arg2: repoDir
     #        arg3: remoteName
     #        arg4: branchName
-    # Version: 0.0.4
+    # Version: 0.0.8
     # 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
     #             [3]: Test if dir is (in) git repository. https://stackoverflow.com/a/39518382
+    # Note: Pulls use '--ff-only' option which requires an upstream branch be set.
+    #   This can be done by using:
+    #     $ git branch --set-upstream-to origin/master master
+    # 
     #==BEGIN Validate input arguments==
     arg1="$1";
     arg2="$2";
@@ -47,6 +49,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].
@@ -67,17 +72,19 @@ 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";
     yell "STATUS:Pulling branch $branchName from remote $remoteName";
-    git pull "$remoteName" "$branchName";
+    git pull --ff-only "$remoteName" "$branchName";
+    git fetch "$remoteName";
     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 sample code
 tmpDir=/tmp/"$(date +%Y%m%dT%H%M%S%z)";