Renamed GitFetch to GitRemove
This commit is contained in:
parent
a7af83b482
commit
0f35ecd942
16
README.md
16
README.md
@ -12,14 +12,18 @@ cd REDMINE_ROOT/plugins
|
|||||||
git clone https://github.com/dergachev/redmine_git_remote
|
git clone https://github.com/dergachev/redmine_git_remote
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Then enable the new GitRemote SMC 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)
|
||||||
|
|
||||||
Be sure to install the appropriate SSH keys to `~/.ssh/id_rsa` (for your redmine user).
|
Be sure to install the appropriate SSH keys to `~/.ssh/id_rsa` (for your redmine user).
|
||||||
I recommend creating a dedicated deployment user on github/gitlab for this purpose.
|
I recommend creating a dedicated deployment user on github/gitlab for this purpose.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
This plugin defines a new repository type, GitFetch, which allows you to associate
|
This plugin defines a new repository type, GitRemote, which allows you to associate
|
||||||
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
|
||||||
GitFetch, 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)
|
![](https://dl.dropbox.com/u/29440342/screenshots/ATIAQXHG-2014.11.27-15-03-51.png)
|
||||||
|
|
||||||
@ -42,7 +46,13 @@ 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):
|
||||||
|
|
||||||
```
|
```
|
||||||
cd /home/redmine/redmine && ./script/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:
|
||||||
|
|
||||||
|
```
|
||||||
|
cd /home/redmine/redmine && ./script/rails runner "Repository.fetch_changesets" -e production
|
||||||
```
|
```
|
||||||
|
|
||||||
Note GitRemote doesn't delete the cloned repos when the associated record is deleted from Redmine.
|
Note GitRemote doesn't delete the cloned repos when the associated record is deleted from Redmine.
|
||||||
|
@ -2,7 +2,7 @@ require 'redmine/scm/adapters/git_adapter'
|
|||||||
require 'pathname'
|
require 'pathname'
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
|
|
||||||
class Repository::GitFetch < Repository::Git
|
class Repository::GitRemote < Repository::Git
|
||||||
|
|
||||||
PLUGIN_ROOT = Pathname.new(__FILE__).join("../../../..").realpath.to_s
|
PLUGIN_ROOT = Pathname.new(__FILE__).join("../../../..").realpath.to_s
|
||||||
PATH_PREFIX = PLUGIN_ROOT + "/repos/"
|
PATH_PREFIX = PLUGIN_ROOT + "/repos/"
|
||||||
@ -62,7 +62,7 @@ class Repository::GitFetch < Repository::Git
|
|||||||
end
|
end
|
||||||
|
|
||||||
def clone_empty
|
def clone_empty
|
||||||
Repository::GitFetch.add_known_host(clone_host)
|
Repository::GitRemote.add_known_host(clone_host)
|
||||||
|
|
||||||
unless system "git ls-remote -h #{clone_url}"
|
unless system "git ls-remote -h #{clone_url}"
|
||||||
return "#{clone_url} is not a valid remote."
|
return "#{clone_url} is not a valid remote."
|
||||||
@ -86,7 +86,7 @@ class Repository::GitFetch < Repository::Git
|
|||||||
|
|
||||||
unloadable
|
unloadable
|
||||||
def self.scm_name
|
def self.scm_name
|
||||||
'GitFetch'
|
'GitRemote'
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse(url)
|
def parse(url)
|
||||||
@ -107,7 +107,7 @@ class Repository::GitFetch < Repository::Git
|
|||||||
|
|
||||||
def fetch
|
def fetch
|
||||||
puts "Fetching repo #{clone_path}"
|
puts "Fetching repo #{clone_path}"
|
||||||
Repository::GitFetch.add_known_host(clone_host)
|
Repository::GitRemote.add_known_host(clone_host)
|
||||||
|
|
||||||
err = clone_empty
|
err = clone_empty
|
||||||
Rails.logger.warn err if err
|
Rails.logger.warn err if err
|
||||||
@ -118,12 +118,6 @@ class Repository::GitFetch < Repository::Git
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.fetch_all
|
|
||||||
Repository::GitFetch.all.each do |x|
|
|
||||||
x.fetch
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Checks if host is in ~/.ssh/known_hosts, adds it if not present
|
# Checks if host is in ~/.ssh/known_hosts, adds it if not present
|
||||||
def self.add_known_host(host)
|
def self.add_known_host(host)
|
||||||
# if not found...
|
# if not found...
|
@ -1,4 +1,4 @@
|
|||||||
en:
|
en:
|
||||||
field_extra_clone_url: Clone URL
|
field_extra_clone_url: Clone URL
|
||||||
text_git_fetch_repository_note: The URL to clone from.
|
text_git_remote_url_note: The URL to clone from.
|
||||||
text_git_fetch_repository_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.
|
||||||
|
11
init.rb
11
init.rb
@ -3,17 +3,16 @@ require 'redmine'
|
|||||||
# TODO: why isn't this autoloaded?
|
# TODO: why isn't this autoloaded?
|
||||||
# NB: at this point, $PATH only contains {PLUGINS}/lib and app/models, app/controllers
|
# NB: at this point, $PATH only contains {PLUGINS}/lib and app/models, app/controllers
|
||||||
# but not {PLUGINS}/app/models. Maybe those get added later?
|
# but not {PLUGINS}/app/models. Maybe those get added later?
|
||||||
require File.dirname(__FILE__) + '/app/models/repository/git_fetch'
|
require File.dirname(__FILE__) + '/app/models/repository/git_remote'
|
||||||
|
|
||||||
require_dependency "repository_fetch/repositories_helper_patch"
|
require_dependency "repository_fetch/repositories_helper_patch"
|
||||||
|
|
||||||
Redmine::Scm::Base.add "GitFetch"
|
Redmine::Scm::Base.add "GitRemote"
|
||||||
|
|
||||||
Redmine::Plugin.register :redmine_repository_fetch do
|
Redmine::Plugin.register :redmine_git_remote do
|
||||||
name 'Repository Fetch'
|
name 'Repository Fetch'
|
||||||
author 'Alex Dergachev'
|
author 'Alex Dergachev'
|
||||||
url 'https://github.com/dergachev/redmine_repository_fetch'
|
url 'https://github.com/dergachev/redmine_git_remote'
|
||||||
description 'Automatically clone and fetch referenced repositories'
|
description 'Automatically clone and fetch remote git repositories'
|
||||||
version '0.0.1'
|
version '0.0.1'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -5,17 +5,17 @@ module RepositoryFetch
|
|||||||
end
|
end
|
||||||
|
|
||||||
module InstanceMethods
|
module InstanceMethods
|
||||||
def git_fetch_field_tags(form, repository)
|
def git_remote_field_tags(form, repository)
|
||||||
#TODO: change URL label to "Path"
|
#TODO: change URL label to "Path"
|
||||||
content_tag('p', form.text_field(:url, :size => 60, :required => true,
|
content_tag('p', form.text_field(:url, :size => 60, :required => true,
|
||||||
:disabled => !repository.safe_attribute?('url'), :required => false) +
|
:disabled => !repository.safe_attribute?('url'), :required => false) +
|
||||||
content_tag('em',
|
content_tag('em',
|
||||||
l(:text_git_fetch_repository_path_note),
|
l(:text_git_remote_path_note),
|
||||||
:class => 'info') +
|
: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')) +
|
||||||
content_tag('em',
|
content_tag('em',
|
||||||
l(:text_git_fetch_repository_note),
|
l(:text_git_remote_url_note),
|
||||||
:class => 'info')
|
:class => 'info')
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user