Compare commits
10 Commits
8516466c19
...
230793baf6
Author | SHA1 | Date | |
---|---|---|---|
|
230793baf6 | ||
|
b045626ab9 | ||
|
18f167930b | ||
|
25180d0909 | ||
|
f384527b15 | ||
|
e25577c5ab | ||
|
c76cd25d3e | ||
|
04d5f405ae | ||
|
4e2b417bf8 | ||
|
b858a1f1ca |
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.DS_Store
|
12
README.md
12
README.md
@ -14,7 +14,7 @@ git clone https://github.com/dergachev/redmine_git_remote
|
||||
|
||||
Then enable the new GitRemote SCM type in [http://redmine-root/settings?tab=repositories](http://redmine-root/settings?tab=repositories)
|
||||
|
||||

|
||||

|
||||
|
||||
The plugin shells out to the following binaries, so make sure they're available:
|
||||
* git 1.7.5+ - a version recent enough to support `get remote add --mirror=fetch origin URL`
|
||||
@ -49,7 +49,7 @@ This plugin defines a new repository type, GitRemote, which allows you to associ
|
||||
a remote repository with your Redmine project. First create a new repository of type
|
||||
GitRemote, enter the clone URL. The identifier and path will be auto-generated, but can be overriden.
|
||||
|
||||

|
||||

|
||||
|
||||
On submitting the repository creation form, the identifier and `url`
|
||||
(filesystem path) fields will be auto-generated (if not explicitly provided).
|
||||
@ -71,18 +71,18 @@ automatically" setting at
|
||||
and relying on the following cron job as per [Redmine Wiki Instructions](http://www.redmine.org/projects/redmine/wiki/RedmineRepositories):
|
||||
|
||||
```
|
||||
*/5 * * * * cd /home/redmine/redmine && ./script/rails runner \"Repository.fetch_changesets\" -e production >> log/cron_rake.log 2>&1
|
||||
*/5 * * * * cd /home/redmine/redmine && ./bin/rails runner Repository.fetch_changesets -e production >> log/cron_rake.log 2>&1
|
||||
```
|
||||
|
||||
To trigger fetch manually, run this:
|
||||
|
||||
```
|
||||
cd /home/redmine/redmine && ./script/rails runner "Repository.fetch_changesets" -e production
|
||||
cd /home/redmine/redmine && ./bin/rails runner "Repository.fetch_changesets" -e production
|
||||
```
|
||||
|
||||
Notes:
|
||||
|
||||
* Tested on Redmine 2.6 and ruby 2.1
|
||||
* Tested on Redmine 3.4 and ruby 2.3
|
||||
* Currently alpha state, use at your own risk. Given possible security risks of shelling out,
|
||||
we recommend using this plugin only if all RedMine project admins are trusted users.
|
||||
* This plugin doesn't clean-up (delete) cloned repos from the file system when the record
|
||||
@ -92,5 +92,5 @@ Notes:
|
||||
This snippet should make the error go away:
|
||||
|
||||
```
|
||||
./script/rails runner 'ActiveRecord::Base.connection.execute("UPDATE repositories SET type=\"Repository::Git\" WHERE type = \"Repository::GitRemote\")' -e production
|
||||
./bin/rails runner 'ActiveRecord::Base.connection.execute("UPDATE repositories SET type=\"Repository::Git\" WHERE type = \"Repository::GitRemote\")' -e production
|
||||
```
|
||||
|
2
after_init.rb
Normal file
2
after_init.rb
Normal file
@ -0,0 +1,2 @@
|
||||
require 'redmine'
|
||||
require File.dirname(__FILE__) + '/lib/redmine_git_remote'
|
@ -2,15 +2,13 @@ require 'redmine/scm/adapters/git_adapter'
|
||||
require 'pathname'
|
||||
require 'fileutils'
|
||||
# require 'open3'
|
||||
require_dependency 'redmine_git_remote/poor_mans_capture3'
|
||||
|
||||
class Repository::GitRemote < Repository::Git
|
||||
|
||||
PLUGIN_ROOT = Pathname.new(__FILE__).join("../../../..").realpath.to_s
|
||||
PATH_PREFIX = PLUGIN_ROOT + "/repos/"
|
||||
|
||||
before_validation :initialize_clone
|
||||
|
||||
safe_attributes 'extra_info', :if => lambda {|repository, _user| repository.new_record?}
|
||||
|
||||
# TODO: figure out how to do this safely (if at all)
|
||||
# before_deletion :rm_removed_repo
|
||||
# def rm_removed_repo
|
||||
@ -79,7 +77,11 @@ class Repository::GitRemote < Repository::Git
|
||||
|
||||
p = parse(attributes["extra_info"]["extra_clone_url"])
|
||||
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
|
||||
errors.add :extra_clone_url, err if err
|
||||
|
7
app/views/settings/_git_remote_settings.html.erb
Normal file
7
app/views/settings/_git_remote_settings.html.erb
Normal 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>
|
@ -2,3 +2,7 @@ en:
|
||||
field_extra_clone_url: Clone URL
|
||||
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.
|
||||
config:
|
||||
title: Git Remote Settings
|
||||
repo_clone_path: Repository clone path
|
||||
clone_path_hint: Path where repository is cloned. Relative to plugin directory.
|
||||
|
BIN
images/available-scm.png
Normal file
BIN
images/available-scm.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 32 KiB |
BIN
images/git-remote-config.png
Normal file
BIN
images/git-remote-config.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 45 KiB |
16
init.rb
16
init.rb
@ -1,5 +1,3 @@
|
||||
require 'redmine'
|
||||
require_dependency "redmine_git_remote/repositories_helper_patch"
|
||||
|
||||
Redmine::Scm::Base.add "GitRemote"
|
||||
|
||||
@ -8,5 +6,17 @@ Redmine::Plugin.register :redmine_git_remote do
|
||||
author 'Alex Dergachev'
|
||||
url 'https://github.com/dergachev/redmine_git_remote'
|
||||
description 'Automatically clone and fetch remote git repositories'
|
||||
version '0.0.1'
|
||||
version '0.0.2'
|
||||
|
||||
requires_redmine version_or_higher: '5.0.0'
|
||||
|
||||
settings partial: 'settings/git_remote_settings',
|
||||
default: {
|
||||
'git_remote_repo_clone_path' => Pathname.new(__FILE__).join("../").realpath.to_s + "/repos"
|
||||
}
|
||||
|
||||
end
|
||||
|
||||
unless Redmine::Plugin.installed?(:easy_extensions)
|
||||
require_relative 'after_init'
|
||||
end
|
@ -7,12 +7,12 @@ module RedmineGitRemote
|
||||
module InstanceMethods
|
||||
def git_remote_field_tags(form, repository)
|
||||
content_tag('p', form.text_field(:url,
|
||||
:size => 60, :required => true, :required => false,
|
||||
:size => 60, :required => false,
|
||||
:disabled => !repository.safe_attribute?('url'),
|
||||
:label => l(:field_path_to_repository)) +
|
||||
content_tag('em', l(:text_git_remote_path_note), :class => 'info') +
|
||||
form.text_field(:extra_clone_url, :size => 60, :required => true,
|
||||
:disabled => !repository.safe_attribute?('url')) +
|
||||
:disabled => !repository.safe_attribute?('url'), name: 'repository[extra_info][extra_clone_url]') +
|
||||
content_tag('em', l(:text_git_remote_url_note), :class => 'info')
|
||||
)
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user