def mark():
    """
    Mark the start time for active work on an issue
    """
    branch = git.branch
    issue = jira.get_issue(branch)
    if not issue:
        return
    worklogs = jira.get_worklog(issue)

    marked = False
    if worklogs:
        # If we have worklogs, change the updated time of the last log to the mark
        marked = jira.touch_last_worklog(issue)
        mark_time = datetime.datetime.now(dateutil.tz.tzlocal()).strftime("%I:%M %p")
        print "Set mark at %s on %s by touching last work log" % (mark_time, branch)
    else:
        # If we don't have worklogs, mark the issue as in progress if that is an available transition
        jira.workflow_transition(issue, 'Open')
        marked = jira.workflow_transition(issue, 'In Progress')
        mark_time = datetime.datetime.now(dateutil.tz.tzlocal()).strftime("%I:%M %p")
        print 'Set mark at %s on %s by changing status to "In Progress"' % (mark_time, branch)

    if not marked:
        print "ERROR: Issue %s is has a status of %s and has no worklogs.  You must log some time or re-open the issue to proceed." % \
            (branch, issue.fields.status.name)
Mark the start time for active work on an issue