comparison init20.gradle @ 183:358fdd20674a

determine branch when hg not available
author smith@nwoca.org
date Mon, 22 Dec 2014 20:44:29 +0000
parents 0de8c0720fb4
children acd8d3b58440
comparison
equal deleted inserted replaced
182:0de8c0720fb4 183:358fdd20674a
487 gradle.ext.environments = environments 487 gradle.ext.environments = environments
488 488
489 } 489 }
490 490
491 491
492 @ToString class BranchInfo { 492 @ToString
493 class BranchInfo {
493 def name 494 def name
494 def stream = "none" 495 def stream = "none"
495 496
496 BranchInfo(name) { 497 BranchInfo(name) {
497 this.name = name 498 this.name = name
510 digest.update(s.bytes); 511 digest.update(s.bytes);
511 new BigInteger(1, digest.digest()).toString(16).padLeft(32, '0') 512 new BigInteger(1, digest.digest()).toString(16).padLeft(32, '0')
512 } 513 }
513 514
514 def determineName() { 515 def determineName() {
515 def branch = "hg branch".execute().text.trim() 516 try {
516 def rawParents = 'hg parents'.execute().text 517 def branch = "hg branch".execute().text.trim()
517 def parent = rawParents.split('\n').find { it.startsWith("branch") }?.split(":")?.getAt(1)?.trim() 518 def rawParents = 'hg parents'.execute().text
518 return parent ?: branch 519 def parent = rawParents.split('\n').find { it.startsWith("branch") }?.split(":")?.getAt(1)?.trim()
520 return parent ?: branch
521 } catch (e) {
522 if(new File('.hg/branch').exists()) {
523 return new File('.hg/branch').text
524 } else {
525 return ''
526 }
527 }
519 } 528 }
520 529
521 void determineStream() { 530 void determineStream() {
522 def flowConfig = new File('.hgflow').exists() ? new File('.hgflow') : new File('../.hgflow') 531 def flowConfig = new File('.hgflow').exists() ? new File('.hgflow') : new File('../.hgflow')
523 if (flowConfig.exists()) { 532 if (flowConfig.exists()) {