Exemple #1
0
def execute(args):
	
	# First validate arguments
	issueID = identifiers.getFullIssueIdFromLeadingSubstr(args.id)
	if issueID == None:
		# ID is required... no good
		print "Could not find issue: " + args.id
		return None

	# Load the existing issue
	issue = IssueFile.readIssueFromDisk(
							config.ISSUES_DIR + "/" + issueID);
	
	# Are we going to use interactive editing?	
	if args.status == None and args.title == None and args.description == None:
		tmpFile = config.GHI_DIR + "/" + "ISSUE_EDIT";
		IssueFile.writeEditableIssueToDisk(tmpFile, issue)
		tmpFileHash = getCmd("git hash-object " + tmpFile)

		subprocess.call([config.GIT_EDITOR, tmpFile])
		issue = IssueFile.readEditableIssueFromDisk(tmpFile)
		
		# Check to see if the tmpFile is unchanged
		if (tmpFileHash == getCmd("git hash-object " + tmpFile)):
			print "No change in Issue data. Issue not updated"
			return None
	
	# Set the status
	if args.status:
		# There is a potential bug here in situations where there is 
		# more than one status with the same value name
		statusUpdate = None
		for k,v in config.STATUS_OPTS.iteritems():
			if args.status == v:
				statusUpdate = k
				break
		
		if statusUpdate != None:
			issue.setStatus(statusUpdate)
		else:
			print "Status does not exist!"
			return None
	
	# Set title
	if args.title:
		issue.setTitle(args.title)
	
	# Set description
	if args.description:
		issue.setDescription(args.description)
	
	# Make changes to index for commit
	issuepath = config.ISSUES_DIR + "/" + issueID
	IssueFile.writeIssueToDisk(issuepath, issue)
	commit_helper.addToIndex(issuepath)
	
	if args.commit:
		commit_helper.commit()