Module: Gitcycle::Discuss

Included in:
Gitcycle
Defined in:
lib/gitcycle/discuss.rb

Instance Method Summary collapse

Instance Method Details

#discuss(*issues) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/gitcycle/discuss.rb', line 4

def discuss(*issues)
  require_git && require_config

  if issues.empty?
    branch = create_pull_request

    if branch == false
      puts "Branch not found.\n".red
    elsif branch['issue_url']
      puts "\nLabeling issue as 'Discuss'.\n".green
      get('label',
        'branch[name]' => branch['name'],
        'labels' => [ 'Discuss' ]
      )

      puts "Opening issue: #{branch['issue_url']}\n".green
      Launchy.open(branch['issue_url'])
    else
      puts "You must push code before opening a pull request.\n".red
    end
  else
    puts "\nRetrieving branch information from gitcycle.\n".green

    get('branch', 'issues' => issues, 'scope' => 'repo').each do |branch|
      if branch['issue_url']
        puts "Opening issue: #{branch['issue_url']}\n".green
        Launchy.open(branch['issue_url'])
      end
    end
  end
end