Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This should address #106, but probably should be reviewed. #108

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/views/projects/_git_urls.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<script type="text/javascript">

guProjectName= "<%= (@project.parent ? GitHosting::get_full_parent_path(@project, false) + "/" : "" ) %>" + "<%= @project.repository.url %>".replace(/^.*\//, "")
guProjectName= "<%= (@project.parent ? Setting.plugin_redmine_git_hosting['gitRepositoriesUseParentPath'] ? GitHosting::get_full_parent_path(@project, false) + '/' : '' : '' ) %>" + "<%= @project.repository.url %>".replace(/^.*\//, "")
guProjectIsPublic= <%= project.is_public.to_s %> ;
guUser= "<%= User.current.login %>"
guUserIsCommitter= <%= User.current.allowed_to?(:commit_access, project) ? "true" : "false" %> ;
Expand Down
5 changes: 5 additions & 0 deletions app/views/settings/_redmine_git_hosting.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
<%= select_tag("settings[deleteGitRepositories]", options_for_select([[l(:label_enabled), 'true'], [l(:label_disabled), 'false']], @settings['deleteGitRepositories'])) %>
<br />
</p>
<p>
<label><%= l(:label_git_repositories_use_parent_path)%></label>
<%= select_tag("settings[gitRepositoriesUseParentPath]", options_for_select([[l(:label_enabled), 'true'], [l(:label_disabled), 'false']], @settings['gitRepositoriesUseParentPath'])) %>
<br />
</p>
<p>
<label><%= l(:label_git_show_urls)%></label>
<%= select_tag("settings[gitRepositoriesShowUrl]", options_for_select([[l(:label_enabled), 'true'], [l(:label_disabled), 'false']], @settings['gitRepositoriesShowUrl'])) %>
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'en':
label_all_git: Automatically Initialize Git Repositories For New Projects
label_delete_git_repositories: Delete Git Repository When Project is Deleted
label_git_repositories_use_parent_path: Use Parent Projects for Subdirectories
label_git_server: Gitolite Server Domain
label_http_server: HTTP Server Domain (for git http urls)
label_git_user: Git Username
Expand Down
1 change: 1 addition & 0 deletions init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
'gitoliteIdentityPublicKeyFile' => RAILS_ROOT + '/.ssh/gitolite_admin_id_rsa.pub',
'allProjectsUseGit' => 'false',
'deleteGitRepositories' => 'false',
'gitRepositoriesUseParentPath' => 'false',
'gitRepositoriesShowUrl' => 'true',
'gitCacheMaxTime' => '-1',
'gitCacheMaxElements' => '100',
Expand Down
16 changes: 9 additions & 7 deletions lib/git_hosting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,19 @@ def self.sudo_web_to_git_user

def self.get_full_parent_path(project, is_file_path)
parent_parts = [];
p = project
while p.parent
parent_id = p.parent.identifier.to_s
parent_parts.unshift(parent_id)
p = p.parent
if Setting.plugin_redmine_git_hosting['gitRepositoriesUseParentPath'] == 'true'
p = project
while p.parent
parent_id = p.parent.identifier.to_s
parent_parts.unshift(parent_id)
p = p.parent
end
end
return is_file_path ? File.join(parent_parts) : parent_parts.join("/")
end

def self.repository_name project
return "#{get_full_parent_path(project, false)}/#{project.identifier}".sub(/^\//, "")
return "#{get_full_parent_path(project, false)}/#{project.identifier}".sub(/^\/+/, "")
end

def self.repository_path project
Expand All @@ -136,7 +138,7 @@ def self.add_route_for_project(p)
def self.add_route_for_project_with_map(p,m)
repo = p.repository
if repo.is_a?(Repository::Git)
repo_name= p.parent ? File.join(GitHosting::get_full_parent_path(p, true),p.identifier) : p.identifier
repo_name = GitHosting::repository_name(p)
repo_path = repo_name + ".git"
m.connect repo_path, :controller => 'git_http', :p1 => '', :p2 =>'', :p3 =>'', :id=>"#{p[:identifier]}", :path=>"#{repo_path}"
m.connect repo_path, :controller => 'git_http', :p1 => '', :p2 =>'', :p3 =>'', :id=>"#{p[:identifier]}", :path=>"#{repo_path}"
Expand Down
3 changes: 3 additions & 0 deletions lib/git_hosting/patches/projects_controller_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ def disable_git_daemon_if_not_public
end

def update_git_repo_for_new_parent
# this is basically unneeded if not moving repos to sub directories
# but using the configurable flag, it just means the old location will equal the new location
# it might still be best to use a check to disable running this function completely if the flag is set.
if @project.repository != nil
if @project.repository.is_a?(Repository::Git)
old_parent_id = @project.parent ? @project.parent.id : nil
Expand Down