Merge pull request #50 from flozzone/clone_path_setting

Clone path setting
This commit is contained in:
Alex Dergachev 2020-06-17 18:30:15 -04:00 committed by GitHub
commit b045626ab9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 5 deletions

View File

@ -6,9 +6,6 @@ require_dependency 'redmine_git_remote/poor_mans_capture3'
class Repository::GitRemote < Repository::Git class Repository::GitRemote < Repository::Git
PLUGIN_ROOT = Pathname.new(__FILE__).join("../../../..").realpath.to_s
PATH_PREFIX = PLUGIN_ROOT + "/repos/"
before_validation :initialize_clone before_validation :initialize_clone
safe_attributes 'extra_info', :if => lambda {|repository, _user| repository.new_record?} safe_attributes 'extra_info', :if => lambda {|repository, _user| repository.new_record?}
@ -81,7 +78,11 @@ class Repository::GitRemote < Repository::Git
p = parse(attributes["extra_info"]["extra_clone_url"]) p = parse(attributes["extra_info"]["extra_clone_url"])
self.identifier = p[:identifier] if identifier.empty? self.identifier = p[:identifier] if identifier.empty?
self.url = PATH_PREFIX + p[:path] if url.empty?
base_path = Setting.plugin_redmine_git_remote['git_remote_repo_clone_path']
base_path = base_path + "/" unless base_path.end_with?("/")
self.url = base_path + p[:path] if url.empty?
err = ensure_possibly_empty_clone_exists err = ensure_possibly_empty_clone_exists
errors.add :extra_clone_url, err if err errors.add :extra_clone_url, err if err

View File

@ -0,0 +1,7 @@
<h3><%= t('config.title') %></h3>
<p>
<label><%= t('config.repo_clone_path') %></label>
<%= text_field_tag 'settings[git_remote_repo_clone_path]', @settings['git_remote_repo_clone_path'], :size => '60' %>
<%= t('config.clone_path_hint') %>
</p>

View File

@ -2,3 +2,7 @@ en:
field_extra_clone_url: Clone URL field_extra_clone_url: Clone URL
text_git_remote_url_note: The URL to clone from. text_git_remote_url_note: The URL to clone from.
text_git_remote_path_note: The absolute filesystem path to clone to. Leave blank to auto-populate from URL. text_git_remote_path_note: The absolute filesystem path to clone to. Leave blank to auto-populate from URL.
config:
title: Git Remote Settings
repo_clone_path: Repository clone path
clone_path_hint: Path where repository is cloned. Relative to plugin directory.

View File

@ -8,5 +8,9 @@ Redmine::Plugin.register :redmine_git_remote do
author 'Alex Dergachev' author 'Alex Dergachev'
url 'https://github.com/dergachev/redmine_git_remote' url 'https://github.com/dergachev/redmine_git_remote'
description 'Automatically clone and fetch remote git repositories' description 'Automatically clone and fetch remote git repositories'
version '0.0.1' version '0.0.2'
settings :default => {
'git_remote_repo_clone_path' => Pathname.new(__FILE__).join("../").realpath.to_s + "/repos",
}, :partial => 'settings/git_remote_settings'
end end