def updateTrackerGitInfo(self, branch=None, ref=None): """Updates the git info on the tracker issue""" if branch == None: branch = self.currentBranch() if branch == 'HEAD': raise Exception('Cannot update the tracker when on detached branch') # Parsing the branch parsedbranch = parseBranch(branch, C.get('wording.branchRegex')) if not parsedbranch: raise Exception('Could not extract issue number from %s' % branch) issue = 'MDL-%s' % (parsedbranch['issue']) version = parsedbranch['version'] # Get the jira config repositoryurl = C.get('repositoryUrl') diffurltemplate = C.get('diffUrlTemplate') stablebranch = self.get('stablebranch') # Get the hash of the last upstream commit headcommit = None logging.info('Searching for the head commit...') if ref: try: headcommit = self.git().hashes(ref=ref, limit=1, format='%h')[0] except GitException: logging.warning('Could not resolve a head commit using the reference: %s' % (ref)) headcommit = None # No reference was passed, or it was invalid. if not headcommit: headcommit = self.headcommit(branch) # Head commit not resolved if not headcommit: logging.error('Head commit not resolved, aborting update of tracker fields') return False logging.debug('Head commit resolved to %s' % (headcommit)) J = Jira() diffurl = diffurltemplate.replace('%branch%', branch).replace('%stablebranch%', stablebranch).replace('%headcommit%', headcommit) fieldrepositoryurl = C.get('tracker.fieldnames.repositoryurl') fieldbranch = C.get('tracker.fieldnames.%s.branch' % version) fielddiffurl = C.get('tracker.fieldnames.%s.diffurl' % version) if not fieldrepositoryurl or not fieldbranch or not fielddiffurl: logging.error('Cannot set tracker fields for this version (%s). The field names are not set in the config file.', version) else: logging.info('Setting tracker fields: \n %s: %s \n %s: %s \n %s: %s' % (fieldrepositoryurl, repositoryurl, fieldbranch, branch, fielddiffurl, diffurl)) J.setCustomFields(issue, {fieldrepositoryurl: repositoryurl, fieldbranch: branch, fielddiffurl: diffurl})
def updateTrackerGitInfo(self, branch=None): """Updates the git info on the tracker issue""" if branch == None: branch = self.currentBranch() if branch == "HEAD": raise Exception("Cannot update the tracker when on detached branch") # Parsing the branch parsedbranch = parseBranch(branch, C.get("wording.branchRegex")) if not parsedbranch: raise Exception("Could not extract issue number from %s" % branch) issue = "MDL-%s" % (parsedbranch["issue"]) version = parsedbranch["version"] # Get the jira config repositoryurl = C.get("repositoryUrl") diffurltemplate = C.get("diffUrlTemplate") stablebranch = self.get("stablebranch") upstreamremote = C.get("upstreamRemote") # Get the hash of the last upstream commit ref = "%s/%s" % (upstreamremote, stablebranch) headcommit = self.git().hashes(ref=ref, limit=1)[0] J = Jira() diffurl = ( diffurltemplate.replace("%branch%", branch) .replace("%stablebranch%", stablebranch) .replace("%headcommit%", headcommit) ) fieldrepositoryurl = C.get("tracker.fieldnames.repositoryurl") fieldbranch = C.get("tracker.fieldnames.%s.branch" % version) fielddiffurl = C.get("tracker.fieldnames.%s.diffurl" % version) if not (fieldrepositoryurl or fieldbranch or fielddiffurl): logging.error( "Cannot set tracker fields for this version (%s). The field names are not set in the config file.", version, ) else: logging.info( "Setting tracker fields: \n\t%s: %s \n\t%s: %s \n\t%s: %s" % (fieldrepositoryurl, repositoryurl, fieldbranch, branch, fielddiffurl, diffurl) ) J.setCustomFields(issue, {fieldrepositoryurl: repositoryurl, fieldbranch: branch, fielddiffurl: diffurl})
def updateTrackerGitInfo(self, branch=None): """Updates the git info on the tracker issue""" if branch == None: branch = self.currentBranch() if branch == 'HEAD': raise Exception('Cannot update the tracker when on detached branch') # Parsing the branch parsedbranch = parseBranch(branch, C.get('wording.branchRegex')) if not parsedbranch: raise Exception('Could not extract issue number from %s' % branch) issue = 'MDL-%s' % (parsedbranch['issue']) version = parsedbranch['version'] # Get the jira config repositoryurl = C.get('repositoryUrl') diffurltemplate = C.get('diffUrlTemplate') stablebranch = self.get('stablebranch') upstreamremote = C.get('upstreamRemote') # Get the hash of the last upstream commit ref = '%s/%s' % (upstreamremote, stablebranch) headcommit = self.git().hashes(ref=ref, limit=1, format='%h')[0] J = Jira() diffurl = diffurltemplate.replace('%branch%', branch).replace('%stablebranch%', stablebranch).replace('%headcommit%', headcommit) fieldrepositoryurl = C.get('tracker.fieldnames.repositoryurl') fieldbranch = C.get('tracker.fieldnames.%s.branch' % version) fielddiffurl = C.get('tracker.fieldnames.%s.diffurl' % version) if not (fieldrepositoryurl or fieldbranch or fielddiffurl): logging.error('Cannot set tracker fields for this version (%s). The field names are not set in the config file.', version) else: logging.info('Setting tracker fields: \n\t%s: %s \n\t%s: %s \n\t%s: %s' % (fieldrepositoryurl, repositoryurl, fieldbranch, branch, fielddiffurl, diffurl)) J.setCustomFields(issue, {fieldrepositoryurl: repositoryurl, fieldbranch: branch, fielddiffurl: diffurl})