summaryrefslogtreecommitdiff
path: root/app/models/blob_viewer
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2017-05-17 18:00:13 +0000
committerRémy Coutable <remy@rymai.me>2017-05-17 18:00:13 +0000
commitd1bce8ea75df00970f3d4a67587ceb64bf4ec905 (patch)
treebc6c9af3d218b0f32f75b19744e4314f05141be6 /app/models/blob_viewer
parent17e799980f6aaa6b378469f3e237c713f293e079 (diff)
downloadgitlab-ce-d1bce8ea75df00970f3d4a67587ceb64bf4ec905.tar.gz
Add auxiliary blob viewer for CHANGELOG
Diffstat (limited to 'app/models/blob_viewer')
-rw-r--r--app/models/blob_viewer/base.rb2
-rw-r--r--app/models/blob_viewer/changelog.rb16
-rw-r--r--app/models/blob_viewer/license.rb2
3 files changed, 19 insertions, 1 deletions
diff --git a/app/models/blob_viewer/base.rb b/app/models/blob_viewer/base.rb
index c7b8fbfc56a..26a3778c2a3 100644
--- a/app/models/blob_viewer/base.rb
+++ b/app/models/blob_viewer/base.rb
@@ -11,6 +11,8 @@ module BlobViewer
attr_reader :blob
attr_accessor :override_max_size
+ delegate :project, to: :blob
+
def initialize(blob)
@blob = blob
end
diff --git a/app/models/blob_viewer/changelog.rb b/app/models/blob_viewer/changelog.rb
new file mode 100644
index 00000000000..0464ae27f71
--- /dev/null
+++ b/app/models/blob_viewer/changelog.rb
@@ -0,0 +1,16 @@
+module BlobViewer
+ class Changelog < Base
+ include Auxiliary
+ include Static
+
+ self.partial_name = 'changelog'
+ self.file_types = %i(changelog)
+ self.binary = false
+
+ def render_error
+ return if project.repository.tag_count > 0
+
+ :no_tags
+ end
+ end
+end
diff --git a/app/models/blob_viewer/license.rb b/app/models/blob_viewer/license.rb
index 6751ea15a5d..57355f2c3aa 100644
--- a/app/models/blob_viewer/license.rb
+++ b/app/models/blob_viewer/license.rb
@@ -8,7 +8,7 @@ module BlobViewer
self.binary = false
def license
- blob.project.repository.license
+ project.repository.license
end
def render_error