You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2018/01/21 20:19:34 UTC

[sling-site] 02/04: Ensure that includes/Git does not choke on untracked files

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-site.git

commit 6b1023d3bc9e95a8b3e5863afe12dcf021623d36
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Sat Jan 20 11:32:16 2018 +0200

    Ensure that includes/Git does not choke on untracked files
---
 src/main/jbake/templates/includes/Git.groovy | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/main/jbake/templates/includes/Git.groovy b/src/main/jbake/templates/includes/Git.groovy
index 9a703fb..3916331 100644
--- a/src/main/jbake/templates/includes/Git.groovy
+++ b/src/main/jbake/templates/includes/Git.groovy
@@ -8,6 +8,12 @@ class Git {
     	def gitCmd = 'git log -1 --format=%h####%ad####%an####%s ' + filename
     	def defaultText = "0####0000####<MISSING>####<MISSING>"
         def gitInfo = includes.OS.exec(gitCmd, defaultText).split("####")
+        // For untracked files the command does not return anything
+        // After committing this will work, but otherwise it produces
+        // cryptic errors, so best avoid it
+        if ( gitInfo.length != 4 ) {
+            gitInfo = defaultText.split("####")
+        } 
     	return [
     		lastCommit : gitInfo[0],
     		date : gitInfo[1],
@@ -15,4 +21,4 @@ class Git {
     		comment : gitInfo[3]
     	]
     }
-}
\ No newline at end of file
+}

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.