Example #1
0
def cmd_summary(mx):
	ekg.echo("Issue: "+mx.group(0))
	try:
		i = r.getIssueByKey(mx.group(0))
		return "%s (%s/%s): %s" % (color.colored(mx.group(0), attrs=['bold']), color.colored(i.raw.reporter, 'green'), color.colored(i.statusName(), 'green', attrs=['bold']), i.raw.summary)
	except jiraError.IssueNotFound:
		return "%s: Issue not found." % mx.group(0)
Example #2
0
def handleSignals():
	dir=ekg.config["jirabot:sigdir"]
	dirList=os.listdir(dir)
	# TODO: move this to "global" scope. It makes no sense to compile it on
	# every message.
	# NOTE: it assumes that prefix added by JIRA is ' ' (single space).
	# Default prefix is '[JIRA]'. Adjust it to your JIRA configuration.
	# TODO: declare ekg2 config variable for prefix.
	subjectrx = re.compile("^  ([^:]+): .(%s-[0-9]+)" % ekg.config["jirabot:projectregexp"])
	for fname in dirList:
		file = open("%s/%s" % (dir, fname), "r")
		subject = file.readline()

		# Extract some information (action, issue key) from mail Subject
		mx = subjectrx.match(subject)

		if mx:
			# a for action, i for issue
			a = mx.group(1)
			i = r.getIssueByKey(mx.group(2))
			# find last comment
			if i._comments:
				latest=max(i._comments, key=lambda x: x.updated)
				if a == "Commented":
					a += " by %s" % latest.updateAuthor
				if a == "Issue Comment Edited":
					a = "%s edited %%s's comment" % latest.updateAuthor % latest.author
			ekg.command("/msg %s %s %s (%s/%s): %s" %
					(ekg.config["jirabot:channel"],
						color.colored(mx.group(2), attrs=['bold']),
						a,
						color.colored(i.raw.reporter, 'green'),
						color.colored(i.statusName(), 'green', attrs=['bold']),
						i.raw.summary))
		file.close()
		os.unlink("%s/%s" % (dir, fname))