Compare commits

..

No commits in common. "230793baf6f0da326062359a472f39083bd7f686" and "8516466c1995f87e20542ae8ed5ef82649477165" have entirely different histories.

10 changed files with 16 additions and 42 deletions

1
.gitignore vendored
View File

@ -1 +0,0 @@
.DS_Store

View File

@ -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) Then enable the new GitRemote SCM type in [http://redmine-root/settings?tab=repositories](http://redmine-root/settings?tab=repositories)
![](images/available-scm.png) ![](https://dl.dropbox.com/u/29440342/screenshots/AYKNZDTB-2014.11.27-15-59-06.png)
The plugin shells out to the following binaries, so make sure they're available: 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` * 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 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. GitRemote, enter the clone URL. The identifier and path will be auto-generated, but can be overriden.
![](images/git-remote-config.png) ![](https://dl.dropbox.com/u/29440342/screenshots/ATIAQXHG-2014.11.27-15-03-51.png)
On submitting the repository creation form, the identifier and `url` On submitting the repository creation form, the identifier and `url`
(filesystem path) fields will be auto-generated (if not explicitly provided). (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): 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 && ./bin/rails runner Repository.fetch_changesets -e production >> log/cron_rake.log 2>&1 */5 * * * * cd /home/redmine/redmine && ./script/rails runner \"Repository.fetch_changesets\" -e production >> log/cron_rake.log 2>&1
``` ```
To trigger fetch manually, run this: To trigger fetch manually, run this:
``` ```
cd /home/redmine/redmine && ./bin/rails runner "Repository.fetch_changesets" -e production cd /home/redmine/redmine && ./script/rails runner "Repository.fetch_changesets" -e production
``` ```
Notes: Notes:
* Tested on Redmine 3.4 and ruby 2.3 * Tested on Redmine 2.6 and ruby 2.1
* Currently alpha state, use at your own risk. Given possible security risks of shelling out, * 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. 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 * 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: This snippet should make the error go away:
``` ```
./bin/rails runner 'ActiveRecord::Base.connection.execute("UPDATE repositories SET type=\"Repository::Git\" WHERE type = \"Repository::GitRemote\")' -e production ./script/rails runner 'ActiveRecord::Base.connection.execute("UPDATE repositories SET type=\"Repository::Git\" WHERE type = \"Repository::GitRemote\")' -e production
``` ```

View File

@ -1,2 +0,0 @@
require 'redmine'
require File.dirname(__FILE__) + '/lib/redmine_git_remote'

View File

@ -2,12 +2,14 @@ require 'redmine/scm/adapters/git_adapter'
require 'pathname' require 'pathname'
require 'fileutils' require 'fileutils'
# require 'open3' # require 'open3'
require_dependency 'redmine_git_remote/poor_mans_capture3'
class Repository::GitRemote < Repository::Git class Repository::GitRemote < Repository::Git
before_validation :initialize_clone PLUGIN_ROOT = Pathname.new(__FILE__).join("../../../..").realpath.to_s
PATH_PREFIX = PLUGIN_ROOT + "/repos/"
safe_attributes 'extra_info', :if => lambda {|repository, _user| repository.new_record?} before_validation :initialize_clone
# TODO: figure out how to do this safely (if at all) # TODO: figure out how to do this safely (if at all)
# before_deletion :rm_removed_repo # before_deletion :rm_removed_repo
@ -77,11 +79,7 @@ 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

@ -1,7 +0,0 @@
<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,7 +2,3 @@ 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.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

16
init.rb
View File

@ -1,3 +1,5 @@
require 'redmine'
require_dependency "redmine_git_remote/repositories_helper_patch"
Redmine::Scm::Base.add "GitRemote" Redmine::Scm::Base.add "GitRemote"
@ -6,17 +8,5 @@ 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.2' version '0.0.1'
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 end
unless Redmine::Plugin.installed?(:easy_extensions)
require_relative 'after_init'
end

View File

@ -7,12 +7,12 @@ module RedmineGitRemote
module InstanceMethods module InstanceMethods
def git_remote_field_tags(form, repository) def git_remote_field_tags(form, repository)
content_tag('p', form.text_field(:url, content_tag('p', form.text_field(:url,
:size => 60, :required => false, :size => 60, :required => true, :required => false,
:disabled => !repository.safe_attribute?('url'), :disabled => !repository.safe_attribute?('url'),
:label => l(:field_path_to_repository)) + :label => l(:field_path_to_repository)) +
content_tag('em', l(:text_git_remote_path_note), :class => 'info') + content_tag('em', l(:text_git_remote_path_note), :class => 'info') +
form.text_field(:extra_clone_url, :size => 60, :required => true, form.text_field(:extra_clone_url, :size => 60, :required => true,
:disabled => !repository.safe_attribute?('url'), name: 'repository[extra_info][extra_clone_url]') + :disabled => !repository.safe_attribute?('url')) +
content_tag('em', l(:text_git_remote_url_note), :class => 'info') content_tag('em', l(:text_git_remote_url_note), :class => 'info')
) )
end end