class GitPivotalTrackerIntegration::Command::Report

Constants

V2GPTI_PROJECT_ID

Public Instance Methods

run(args) click to toggle source
# File lib/git-pivotal-tracker-integration/command/report.rb, line 23
def run(args)
  owned_by = 611593   # hard coded to Jeff Wolski for now

  $LOG.debug("#{self.class} in project:#{@project.name} pwd:#{pwd} branch:#{Util::Git.branch_name}")
  bug_title = nil
  bug_title = args[0] if args.length == 1

  # puts bug_title
  abort "\nUsage example:\n\n git report \"Issue running deliver command\" \n" if bug_title.nil? || bug_title.empty?

  report_note = ""
  while (report_note.nil? || report_note.empty?)
    report_note = ask("Description of bug:")
  end

  current_user        = (Util::Shell.exec "git config user.name").chomp
  bug_title           = "User Reported - #{current_user} - #{bug_title}"
  current_user_email  = (Util::Shell.exec "git config user.email").chomp
  bug_description     = "#{@project.name}\n#{current_user_email}\n#{report_note}"

  project     = @client.project(V2GPTI_PROJECT_ID)
  attachment  = project.add_attachment(self.logger_filename, 'text/plain')

  story_params  = {
                    :owner_ids    => [owned_by],
                    :story_type   => "bug",
                    :name         => bug_title,
                    :description  => bug_description,
                    :labels       => ["userreported"]
                  }

  story = project.create_story story_params

  story.add_comment_with_attachment('Log file', attachment)
end