class AssistedWorkflow::Addons::Github

Public Class Methods

new(output, options = {}) click to toggle source
Calls superclass method AssistedWorkflow::Addons::Base::new
# File lib/assisted_workflow/addons/github.rb, line 50
def initialize(output, options = {})
  super
  @client = Octokit::Client.new(:access_token => options["token"])
  
  @repo = options["repository"]
  @username = @client.user.login
end

Public Instance Methods

create_pull_request(branch, story) click to toggle source

Creates a pull request using current branch changes

@param repo [String] Repository name. inaka/assisted_workflow @param branch [String] Branch name. flavio.0001.new_feature @param story [Story] Pivotal story object @return [Sawyer::Resource] The newly created pull request

# File lib/assisted_workflow/addons/github.rb, line 64
def create_pull_request(branch, story)
  log "submiting the new pull request"
  base = "master"
  pull_request = if story.is_a? GithubStory
    @client.create_pull_request_for_issue(@repo, base, branch, story.id)
  else
    title = "[##{story.id}] #{story.name}"
    @client.create_pull_request(@repo, base, branch, title, story.description)
  end
  
  if pull_request.nil?
    raise AssistedWorkflow::Error, "error on submiting the pull request"
  end
  
  url = pull_request._links.html.href
  log "new pull request at #{url}"
  url
end
find_story(story_id) click to toggle source
# File lib/assisted_workflow/addons/github.rb, line 83
def find_story(story_id)
  if !story_id.nil?
    log "loading story ##{story_id}"
    issue = @client.issue(@repo, story_id)
    story = GithubStory.new(issue) if issue
    story
  end
end
finish_story(story, options = {}) click to toggle source
# File lib/assisted_workflow/addons/github.rb, line 100
def finish_story(story, options = {})
  log "finishing story ##{story.id}"
  current_labels = story.labels
  current_labels.delete "started"
  current_labels.push "finished"
  @client.reopen_issue(@repo, story.id, :assignee => @username, :labels => current_labels)
end
pending_stories(options = {}) click to toggle source
# File lib/assisted_workflow/addons/github.rb, line 108
def pending_stories(options = {})
  log "loading pending stories"
  opt = {:state => "open"}
  opt[:assignee] = @username unless options[:include_started]
  issues = @client.issues(@repo, opt)
  issues.map do |issue|
    GithubStory.new(issue)
  end
end
start_story(story, options = {}) click to toggle source
# File lib/assisted_workflow/addons/github.rb, line 92
def start_story(story, options = {})
  log "starting story ##{story.id}"
  current_labels = story.labels
  current_labels.delete "finished"
  current_labels.push "started"
  @client.reopen_issue(@repo, story.id, :assignee => @username, :labels => current_labels)
end
username() click to toggle source
# File lib/assisted_workflow/addons/github.rb, line 122
def username
  @username
end
valid?() click to toggle source
# File lib/assisted_workflow/addons/github.rb, line 118
def valid?
  @client.user_authenticated?
end