예제 #1
0
파일: add.py 프로젝트: lorneliechty/ghi
def execute(args):
	issue = None
	
	# First validate arguments
	if (args.title == None and args.description == None):
		# If no arguments, drop into interactive mode
		tmpFile = config.GHI_DIR + "/" + "ISSUE_EDIT";
		issue = IssueProto()
		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 "Not enough data to create issue. No issue created."
			return None
	
	elif (args.title == None):
		# Title is required... no good
		print "An issue title is required. Try 'add' with no arguments for interactive mode"
		return None
	
	else:
		# Create new issue
		issue = IssueProto();
		
		# Set title
		issue.setTitle(args.title)
		
		# Set description
		if (args.description):
			issue.setDescription(args.description)

	if (issue):
		# Generate an issue ID
		issueID = str(identifiers.genNewIssueID())
		
		# Make changes to index for commit
		issuepath = config.ISSUES_DIR + "/" + issueID
		IssueFile.writeIssueToDisk(issuepath, issue)
		commit_helper.addToIndex(issuepath)
		
		if args.group:
			Group(args.group).addIssue(issueID)
			commit_helper.addToIndex(config.GROUPS_DIR + '/"' + args.group + '"')
		
		# Display the new issue ID to the user
		print issueID
		
		if args.commit:
			commit_helper.commit()
예제 #2
0
파일: edit.py 프로젝트: lorneliechty/ghi
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()