Module: Rubyists::Linear::CLI::Issue
- Includes:
- SubCommands
- Included in:
- Create, Develop, Pr, Update
- Defined in:
- lib/linear/commands/issue.rb,
lib/linear/commands/issue/pr.rb,
lib/linear/commands/issue/list.rb,
lib/linear/commands/issue/take.rb,
lib/linear/commands/issue/create.rb,
lib/linear/commands/issue/update.rb,
lib/linear/commands/issue/develop.rb
Overview
The Issue module is the namespace for all issue-related commands, and should be included in any command that deals with issues
Defined Under Namespace
Classes: Create, Develop, List, Pr, Take, Update
Constant Summary
collapse
- DESCRIPTION =
'Manage issues'
- ALLOWED_PR_TYPES =
'bug|fix|sec(urity)|feat(ure)|chore|refactor|test|docs|style|ci|perf'
- ALIASES =
Aliases for Issue commands
{
create: %w[c new add], develop: %w[d dev], list: %w[l ls], update: %w[u], pr: %w[pull-request], issue: %w[i issues] }.freeze
Instance Method Summary
collapse
#ask_for_team, #branch_for, #choose_a_team!, #current_branch, #default_branch, #git, included, #prompt, #pull_or_push_new_branch!
Methods included from WhatFor
#ask_for_projects, #ask_or_edit, #cancelled_state_for, #comment_for, #completed_state_for, #description_for, #editor_for, #labels_for, #pr_description_for, #pr_scope_for, #pr_title_for, #pr_type_for, #project_for, #project_scores, #reason_for, #team_for, #title_for
Instance Method Details
#attach_project(issue, project_search) ⇒ Object
68
69
70
71
72
|
# File 'lib/linear/commands/issue.rb', line 68
def attach_project(issue, project_search)
project = project_for(issue.team, project_search)
issue.attach_to_project project
prompt.ok "#{issue.identifier} was attached to #{project.name}"
end
|
#cancel_issue(issue, **options) ⇒ Object
37
38
39
40
41
42
43
|
# File 'lib/linear/commands/issue.rb', line 37
def cancel_issue(issue, **options)
reason = reason_for(options[:reason], four: "cancelling #{issue.identifier} - #{issue.title}")
issue, reason
cancel_state = cancel_state_for(issue)
issue.close! state: cancel_state, trash: options[:trash]
prompt.ok "#{issue.identifier} was cancelled"
end
|
#close_issue(issue, **options) ⇒ Object
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/linear/commands/issue.rb', line 45
def close_issue(issue, **options)
cancelled = options[:cancel]
doing = cancelled ? 'cancelling' : 'closing'
done = cancelled ? 'cancelled' : 'closed'
workflow_state = cancelled ? cancelled_state_for(issue) : completed_state_for(issue)
reason = reason_for(options[:reason], four: "#{doing} *#{issue.identifier} - #{issue.title}*")
issue, reason
issue.close! state: workflow_state, trash: options[:trash]
prompt.ok "#{issue.identifier} was #{done}"
end
|
#create_pr!(title:, body:) ⇒ Object
56
57
58
59
60
|
# File 'lib/linear/commands/issue.rb', line 56
def create_pr!(title:, body:)
return `gh pr create -a @me --title "#{title}" --body-file "#{body.path}"` if body.respond_to?(:path)
`gh pr create -a @me --title "#{title}" --body "#{body}"`
end
|
#gimme_da_issue!(issue_id, me: Rubyists::Linear::User.me) ⇒ Object
rubocop:disable Naming/MethodParameterName
95
96
97
98
99
100
101
102
103
104
105
106
107
|
# File 'lib/linear/commands/issue.rb', line 95
def gimme_da_issue!(issue_id, me: Rubyists::Linear::User.me) logger.trace('Looking up issue', issue_id:, me:)
issue = Rubyists::Linear::Issue.find(issue_id)
if issue.assignee && issue.assignee.id == me.id
prompt.say "You are already assigned #{issue_id}"
return issue
end
prompt.say "Assigning issue #{issue_id} to ya"
updated = issue.assign!(me)
logger.trace 'Issue taken', issue: updated
updated
end
|
32
33
34
35
|
# File 'lib/linear/commands/issue.rb', line 32
def (issue, )
issue. (issue, )
prompt.ok "Comment added to #{issue.identifier}"
end
|
#issue_pr(issue, **options) ⇒ Object
62
63
64
65
66
|
# File 'lib/linear/commands/issue.rb', line 62
def issue_pr(issue, **options)
title = options[:title] || pr_title_for(issue)
body = options[:description] || pr_description_for(issue)
create_pr!(title:, body:)
end
|
#make_da_issue!(**options) ⇒ Object
85
86
87
88
89
90
91
92
93
|
# File 'lib/linear/commands/issue.rb', line 85
def make_da_issue!(**options)
title = title_for(options[:title])
description = description_for(options[:description])
team = team_for(options[:team])
labels = labels_for(team, options[:labels])
project = project_for(team, options[:project])
Rubyists::Linear::Issue.create(title:, description:, team:, labels:, project:)
end
|
#update_issue(issue, **options) ⇒ Object
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/linear/commands/issue.rb', line 74
def update_issue(issue, **options)
(issue, options[:comment]) if options[:comment]
return close_issue(issue, **options) if options[:close]
return issue_pr(issue) if options[:pr]
return attach_project(issue, options[:project]) if options[:project]
return if options[:comment]
prompt.warn 'No action taken, no options specified'
prompt.ok 'Issue was not updated'
end
|