summaryrefslogtreecommitdiff
path: root/lib/gitlab/changes_list.rb
diff options
context:
space:
mode:
authorScott Le <scott.lee318@gmail.com>2016-07-28 11:04:57 +0700
committerScott Le <scott.lee318@gmail.com>2016-08-11 23:37:00 +0700
commit6109daf480327581b6e2dcdfffe90464be6c7796 (patch)
tree813f1d607d89c94873ae31633acb9091c8a0e287 /lib/gitlab/changes_list.rb
parent5a33bc984abfb4ee6243c00bbcc71ccd086d2266 (diff)
downloadgitlab-ce-6109daf480327581b6e2dcdfffe90464be6c7796.tar.gz
api for generating new merge request
DRY code + fix rubocop Add more test cases Append to changelog DRY changes list find_url service for merge_requests use GET for getting merge request links remove files rename to get_url_service reduce loop add test case for cross project refactor tiny thing update changelog
Diffstat (limited to 'lib/gitlab/changes_list.rb')
-rw-r--r--lib/gitlab/changes_list.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/gitlab/changes_list.rb b/lib/gitlab/changes_list.rb
new file mode 100644
index 00000000000..95308aca95f
--- /dev/null
+++ b/lib/gitlab/changes_list.rb
@@ -0,0 +1,25 @@
+module Gitlab
+ class ChangesList
+ include Enumerable
+
+ attr_reader :raw_changes
+
+ def initialize(changes)
+ @raw_changes = changes.kind_of?(String) ? changes.lines : changes
+ end
+
+ def each(&block)
+ changes.each(&block)
+ end
+
+ def changes
+ @changes ||= begin
+ @raw_changes.map do |change|
+ next if change.blank?
+ oldrev, newrev, ref = change.strip.split(' ')
+ { oldrev: oldrev, newrev: newrev, ref: ref }
+ end.compact
+ end
+ end
+ end
+end