Skip to content

Commit f6cbc86

Browse files
author
root
committed
Add public_repo option
1 parent 95c2866 commit f6cbc86

File tree

9 files changed

+35
-2
lines changed

9 files changed

+35
-2
lines changed

Diff for: app/helpers/extend_projects_helper.rb

+8
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,12 @@ def git_annex_feature(repository)
8181
return label, css_class, enabled
8282
end
8383

84+
85+
def public_repo_feature(repository)
86+
label = l(:label_public_repo)
87+
css_class = 'fa-users'
88+
enabled = repository.public_repo?
89+
return label, css_class, enabled
90+
end
91+
8492
end

Diff for: app/models/concerns/gitolitable_features.rb

+5
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,9 @@ def protected_branches_enabled?
6767
extra[:protected_branch]
6868
end
6969

70+
71+
def public_repo?
72+
extra[:public_repo]
73+
end
74+
7075
end

Diff for: app/models/repository_git_extra.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class RepositoryGitExtra < ActiveRecord::Base
1414
BOTH = 3
1515

1616
## Attributes
17-
attr_accessible :git_http, :git_daemon, :git_notify, :git_annex, :default_branch, :protected_branch, :key
17+
attr_accessible :git_http, :git_daemon, :git_notify, :git_annex, :default_branch, :protected_branch, :public_repo, :key
1818

1919
## Relations
2020
belongs_to :repository

Diff for: app/views/projects/settings/_repositories.html.haml

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
= render_feature(repository, :git_http)
3535
= render_feature(repository, :git_notify)
3636
= render_feature(repository, :protected_branch)
37+
= render_feature(repository, :public_repo)
3738

3839
%td{ class: 'buttons' }
3940
- if User.current.allowed_to?(:manage_repository, @project)

Diff for: app/views/repositories/_xitolite_options.html.haml

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
= label_tag 'repository_git_extra[protected_branch]', l(:label_enable_protected_branches)
2626
= f.check_box :protected_branch
2727

28+
%p
29+
= label_tag 'repository_git_extra[public_repo]', l(:label_enable_public_repo)
30+
= f.check_box :public_repo
31+
2832
%p
2933
= label_tag 'repository_git_extra[git_http]', l(:label_enable_smart_http)
3034
= f.select :git_http, options_for_select(RepositoryGitExtra::SMART_HTTP_OPTIONS, selected: repository.extra[:git_http].to_s)

Diff for: config/locales/models/repository_xitolite/en.yml

+2
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ en:
2525
label_enable_git_daemon: Enable Git Daemon
2626
label_enable_smart_http: Smart HTTP Mode
2727
label_enable_protected_branches: Enable protected branches
28+
label_enable_public_repo: Make repository public
2829
label_git_daemon: Git Daemon
2930
label_smart_http: Smart HTTP
3031
label_git_notify: Git Notifications
3132
label_protected_branch: Protected Branches
33+
label_public_repo: Public repository
3234
label_repository_default_branch: Repository default branch
3335
label_init_repo_with_readme: Initialize this repository with a README
3436
label_init_repo_with_git_annex: Initialize this repository with GitAnnex

Diff for: config/locales/models/repository_xitolite/fr.yml

+2
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ fr:
2525
label_enable_git_daemon: Activer le daemon Git
2626
label_enable_smart_http: Mode Smart HTTP
2727
label_enable_protected_branches: Activer les branches protégées
28+
label_enable_public_repo: Rendre le dépôt public
2829
label_git_daemon: Daemon Git
2930
label_smart_http: Smart HTTP
3031
label_git_notify: Notifications Git
3132
label_protected_branch: Branches Protégées
33+
label_public_repo: Dépôt public
3234
label_repository_default_branch: Branche par défaut
3335
label_init_repo_with_readme: Initialiser le dépôt avec un fichier README
3436
label_init_repo_with_git_annex: Initialiser le dépôt avec GitAnnex
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class AddPublicRepoToRepositoryGitExtra < ActiveRecord::Migration
2+
3+
def self.up
4+
add_column :repository_git_extras, :public_repo, :boolean, default: false, after: :protected_branch
5+
end
6+
7+
def self.down
8+
remove_column :repository_git_extras, :public_repo
9+
end
10+
11+
end

Diff for: lib/grack/auth.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def authorized_request?
6262
when *RedmineGitHosting::GitAccess::DOWNLOAD_COMMANDS
6363
if user
6464
RedmineGitHosting::GitAccess.new.download_access_check(user, repository, is_ssl?).allowed?
65-
elsif repository.public_project?
65+
elsif repository.public_project? || repository.public_repo?
6666
# Allow clone/fetch for public projects
6767
true
6868
else

0 commit comments

Comments
 (0)