Compare commits

...

10 Commits

Author SHA1 Message Date
Stefan Hirche
230793baf6 update to Redmine 5 2023-02-02 15:44:24 +01:00
Alex Dergachev
b045626ab9
Merge pull request #50 from flozzone/clone_path_setting
Clone path setting
2020-06-17 18:30:15 -04:00
flozzone
18f167930b Increase version to 0.0.2
Git Tag says 0.0.2 but version in plugin is still set to 0.0.2

Signed-off-by: flozzone <flozzone@gmail.com>
2020-05-08 18:26:21 +02:00
flozzone
25180d0909 Make repository clone path configurable via settings.
Signed-off-by: flozzone <flozzone@gmail.com>
2020-05-08 18:25:34 +02:00
Muhammad Inam
f384527b15
Merge pull request #38 from shahinam/fix-readme
Update ReadMe and fix broken images.
2018-03-07 19:07:16 +05:30
Muhammad Inam
e25577c5ab
Merge pull request #37 from Chevich123/master
Add extra_info to safe_attributes. fix #34
2018-03-07 19:06:44 +05:30
Muhammad Inam Ur Rasheed
c76cd25d3e
Update ReadMe and fix broken images. 2018-03-06 11:51:01 +05:30
Andrew Rogachevich
04d5f405ae Add extra_info to safe_attributes 2017-07-31 18:01:40 +03:00
Alex Dergachev
4e2b417bf8 Fix cron typo 2015-10-27 14:51:00 -04:00
Alex Dergachev
b858a1f1ca Fix typo that causes warning; closes #16 2015-09-09 16:25:13 -04:00
10 changed files with 42 additions and 16 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.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)
![](https://dl.dropbox.com/u/29440342/screenshots/AYKNZDTB-2014.11.27-15-59-06.png) ![](images/available-scm.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.
![](https://dl.dropbox.com/u/29440342/screenshots/ATIAQXHG-2014.11.27-15-03-51.png) ![](images/git-remote-config.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 && ./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: 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: 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, * 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:
``` ```
./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
View File

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

View File

@ -2,15 +2,13 @@ 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
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?}
# 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
# def rm_removed_repo # def rm_removed_repo
@ -79,7 +77,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.

BIN
images/available-scm.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

16
init.rb
View File

@ -1,5 +1,3 @@
require 'redmine'
require_dependency "redmine_git_remote/repositories_helper_patch"
Redmine::Scm::Base.add "GitRemote" Redmine::Scm::Base.add "GitRemote"
@ -8,5 +6,17 @@ 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'
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 => true, :required => false, :size => 60, :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')) + :disabled => !repository.safe_attribute?('url'), name: 'repository[extra_info][extra_clone_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