diff options
author | Rémy Coutable <remy@rymai.me> | 2016-04-11 15:49:25 +0200 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-04-18 14:47:50 +0200 |
commit | 13804aba867d19009ca94d820aa7ec650a509f5a (patch) | |
tree | 64c0d9415d81bb3104ba84af3834115f3a8cc5e1 /app/helpers/projects_helper.rb | |
parent | 073c3d15c71a0f877b62c7d3d7417a9721da1dba (diff) | |
download | gitlab-ce-13804aba867d19009ca94d820aa7ec650a509f5a.tar.gz |
Continue implementation of the license template selector and /licenses API endpoint
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'app/helpers/projects_helper.rb')
-rw-r--r-- | app/helpers/projects_helper.rb | 50 |
1 files changed, 15 insertions, 35 deletions
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 0b0cb658b17..81be73937a9 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -216,40 +216,14 @@ module ProjectsHelper end end - def add_contribution_guide_path(project) - if project && !project.repository.contribution_guide - namespace_project_new_blob_path( - project.namespace, - project, - project.default_branch, - file_name: "CONTRIBUTING.md", - commit_message: "Add contribution guide" - ) - end - end - - def add_changelog_path(project) - if project && !project.repository.changelog - namespace_project_new_blob_path( - project.namespace, - project, - project.default_branch, - file_name: "CHANGELOG", - commit_message: "Add changelog" - ) - end - end - - def add_license_path(project) - if project && !project.repository.license - namespace_project_new_blob_path( - project.namespace, - project, - project.default_branch, - file_name: "LICENSE", - commit_message: "Add license" - ) - end + def add_special_file_path(project, file_name:, commit_message: nil) + namespace_project_new_blob_path( + project.namespace, + project, + project.default_branch || 'master', + file_name: file_name, + commit_message: commit_message || "Add #{file_name.downcase}" + ) end def contribution_guide_path(project) @@ -272,7 +246,7 @@ module ProjectsHelper end def license_path(project) - filename_path(project, :license) + filename_path(project, :license_blob) end def version_path(project) @@ -342,6 +316,12 @@ module ProjectsHelper @ref || @repository.try(:root_ref) end + def license_short_name(project) + license = Licensee::License.new(project.repository.license_key) + + license.nickname || license.name + end + private def filename_path(project, filename) |