-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git: merge pull request #2 from juliendms/develop
Extend Issue class
- Loading branch information
Showing
6 changed files
with
118 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
danger-yajp (0.1.2) | ||
danger-yajp (0.1.3) | ||
danger-plugin-api | ||
jira-ruby | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module Yajp | ||
VERSION = '0.1.2' | ||
VERSION = '0.1.3' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'jira-ruby' | ||
|
||
module Danger | ||
# This class extends (aka monkey patch) the `JIRA::Resource::Issue` class with straightforward methods to easily transition and update issues. | ||
# | ||
class JIRA::Resource::Issue | ||
# Get the browse URL of the issue. | ||
# | ||
# @return [String] the URL of the issue | ||
# | ||
def link | ||
"#{ENV['DANGER_JIRA_URL']}/browse/#{key}" | ||
end | ||
|
||
# Update the issue. | ||
# | ||
# @example Update the fields `assignee` and `customfield_11005` | ||
# issue.update(assignee: { name: 'username' }, customfield_11005: 'example') | ||
# | ||
# @param [Hash] fields Fields to update | ||
# | ||
# @return [Boolean] `true` if the issue was updated successfully, `false` otherwise. | ||
# | ||
def update(**fields) | ||
return if fields.empty? | ||
|
||
save({ fields: fields }) | ||
end | ||
|
||
# Transition the issue using the ID of the transition. Transition IDs can be found in Jira under Project Workflow > Edit Workflow in Text Mode. | ||
# The fields that can be updated with this method are only the fields available in the transition screen of the transition. Otherwise use `transition_and_update`. | ||
# | ||
# @example Transition the issue and set the fields `assignee` and `customfield_11005` available on the transition screens | ||
# jira.transition(my_issue, 10, assignee: { name: 'username' }, customfield_11005: 'example') | ||
# | ||
# @param [Integer] transition_id | ||
# @param [Hash] fields Fields that can be updated on the transition screen | ||
# | ||
# @return [Boolean] `true` if the issue was transitioned successfully, `false` otherwise. | ||
# | ||
def transition(transition_id, **fields) | ||
data = { transition: { id: transition_id.to_s } } | ||
data[:fields] = fields unless fields.empty? | ||
|
||
transitions.build.save(data) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters