Skip to content

Commit b045626

Browse files
authored
Merge pull request dergachev#50 from flozzone/clone_path_setting
Clone path setting
2 parents f384527 + 18f1679 commit b045626

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

app/models/repository/git_remote.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66

77
class Repository::GitRemote < Repository::Git
88

9-
PLUGIN_ROOT = Pathname.new(__FILE__).join("../../../..").realpath.to_s
10-
PATH_PREFIX = PLUGIN_ROOT + "/repos/"
11-
129
before_validation :initialize_clone
1310

1411
safe_attributes 'extra_info', :if => lambda {|repository, _user| repository.new_record?}
@@ -81,7 +78,11 @@ def initialize_clone
8178

8279
p = parse(attributes["extra_info"]["extra_clone_url"])
8380
self.identifier = p[:identifier] if identifier.empty?
84-
self.url = PATH_PREFIX + p[:path] if url.empty?
81+
82+
base_path = Setting.plugin_redmine_git_remote['git_remote_repo_clone_path']
83+
base_path = base_path + "/" unless base_path.end_with?("/")
84+
85+
self.url = base_path + p[:path] if url.empty?
8586

8687
err = ensure_possibly_empty_clone_exists
8788
errors.add :extra_clone_url, err if err
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<h3><%= t('config.title') %></h3>
2+
3+
<p>
4+
<label><%= t('config.repo_clone_path') %></label>
5+
<%= text_field_tag 'settings[git_remote_repo_clone_path]', @settings['git_remote_repo_clone_path'], :size => '60' %>
6+
<%= t('config.clone_path_hint') %>
7+
</p>

config/locales/en.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@ en:
22
field_extra_clone_url: Clone URL
33
text_git_remote_url_note: The URL to clone from.
44
text_git_remote_path_note: The absolute filesystem path to clone to. Leave blank to auto-populate from URL.
5+
config:
6+
title: Git Remote Settings
7+
repo_clone_path: Repository clone path
8+
clone_path_hint: Path where repository is cloned. Relative to plugin directory.

init.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,9 @@
88
author 'Alex Dergachev'
99
url 'https://github.com/dergachev/redmine_git_remote'
1010
description 'Automatically clone and fetch remote git repositories'
11-
version '0.0.1'
11+
version '0.0.2'
12+
13+
settings :default => {
14+
'git_remote_repo_clone_path' => Pathname.new(__FILE__).join("../").realpath.to_s + "/repos",
15+
}, :partial => 'settings/git_remote_settings'
1216
end

0 commit comments

Comments
 (0)