Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/atlassian/jira_connect/serializers/branch_entity.rb')
-rw-r--r--lib/atlassian/jira_connect/serializers/branch_entity.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/atlassian/jira_connect/serializers/branch_entity.rb b/lib/atlassian/jira_connect/serializers/branch_entity.rb
new file mode 100644
index 00000000000..c663575b7a8
--- /dev/null
+++ b/lib/atlassian/jira_connect/serializers/branch_entity.rb
@@ -0,0 +1,32 @@
+# frozen_string_literal: true
+
+module Atlassian
+ module JiraConnect
+ module Serializers
+ class BranchEntity < BaseEntity
+ expose :id do |branch|
+ Digest::SHA256.hexdigest(branch.name)
+ end
+ expose :issueKeys do |branch|
+ JiraIssueKeyExtractor.new(branch.name).issue_keys
+ end
+ expose :name
+ expose :lastCommit, using: JiraConnect::Serializers::CommitEntity do |branch, options|
+ options[:project].commit(branch.dereferenced_target)
+ end
+
+ expose :url do |branch, options|
+ project_commits_url(options[:project], branch.name)
+ end
+ expose :createPullRequestUrl do |branch, options|
+ project_new_merge_request_url(
+ options[:project],
+ merge_request: {
+ source_branch: branch.name
+ }
+ )
+ end
+ end
+ end
+ end
+end