Coder Social home page Coder Social logo

redmine_git_remote's Introduction

redmine_git_remote

Redmine plugin to automatically clone and remote git repositories.

Installation

Install the plugin as usual:

cd REDMINE_ROOT/plugins
git clone https://github.com/dergachev/redmine_git_remote

Then enable the new GitRemote SCM type in 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
  • ssh-keyscan
  • ssh-keygen

Supporting private repos

For security sake, we don't support cloning over HTTPS with username password, but only via SSH.

For example:

  • This private repo will fail to clone: https://github.com/dergachev/my-secret-repo
  • Instead, use the SSH form: [email protected]:evolvingweb/my-secret-repo.git

If you're going to use the SSH form, you'll need to install the appropriate SSH keys to ~/.ssh/id_rsa (in the home directory of your redmine webserver user, likely www-data).

Some extra tips:

  • For GitHub/GitLab, we have found it too troublesome to install repository-specific SSH keys. Instead we ended up creating recommend creating a dedicated account for redmine and installing the keys there.
  • On Ubuntu, the www-data user's $HOME is /var/www, and by default it's owned by root. That means you might have to do this before installing Redmine: sudo mkdir /var/www/.ssh; sudo chown www-data:www-data /var/www/.ssh

Usage

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 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).

For example, if you enter https://github.com/dergachev/vagrant-vbox-snapshot as the Clone URL, it will prefill the Identifier and filesystem path fields as follows:

  • Identifier: vagrant-vbox-snapshot
  • Path: REDMINE_PLUGINS_PATH/redmine_git_remote/repos/github.com/dergachev/vagrant-vbox-snapshot

Once the remote URL is validated, the plugin creates an empty clone at the specified path.

This plugin hooks into the core Repository.fetch_changesets to automatically run git fetch --all on all GitRemote managed repositories as Redmine is about to pull in changesets from the local repos.

To avoid slowing down the GUI, we recommend unchecking the "Fetch commits automatically" setting at http://redmine-root/settings?tab=repositories and relying on the following cron job as per Redmine Wiki Instructions:

*/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 && ./bin/rails runner "Repository.fetch_changesets" -e production

Notes:

  • 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 is deleted from Redmine.

  • Currently Redmine will crash if this plugin is uninstalled, as rails can't seem to handle model classes disappearing while db records reference them. 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
    

redmine_git_remote's People

Contributors

chevich123 avatar dergachev avatar flozzone avatar shahinam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

redmine_git_remote's Issues

Redmine 4.0 internal 500 error on navigation to Adminitration -> settings

I just installed the plugin and when i try to navigate its returning 500, is redmine 4.0 is still not supported.

F, [2018-12-22T08:48:09.572547 #1] FATAL -- : F, [2018-12-22T08:48:09.572578 #1] FATAL -- : ActionView::Template::Error (uninitialized constant #<Class:0x0000556b84dab278>::GitRemote): F, [2018-12-22T08:48:09.572762 #1] FATAL -- : 10: <th><%= l(:text_scm_command_version) %></th> 11: </tr> 12: <% Redmine::Scm::Base.all.collect do |choice| %> 13: <% scm_class = "Repository::#{choice}".constantize %> 14: <% text, value = (choice.is_a?(Array) ? choice : [choice, choice]) %> 15: <% setting = :enabled_scm %> 16: <% enabled = Setting.send(setting).include?(value) %> F, [2018-12-22T08:48:09.572796 #1] FATAL -- : F, [2018-12-22T08:48:09.572823 #1] FATAL -- : app/views/settings/_repositories.html.erb:13:in block (2 levels) in _app_views_settings__repositories_html_erb__229153003603049748_46960144877320'

redmine Internal 500 error

hi, @dergachev , the error message "redmine internal 500 error" occured when I add remote github repositories to my redmine, the env of my server is:

system: CentOS release 6.4 (Final)
plugin_path: $redmine_root/redmine_git_remote
ruby: 1.8.7
redmine: 2.6.3
git: 1.7.1

The following is the operation steps:

  1. Add git repositories:
    git0
  2. submit create:
    git2
  3. error message in $redmin_root/log/production.log

Started POST "/projects/manual/repositories" for 10.2.49.220 at Mon Apr 20 19:15:46 +0800 2015
Processing by RepositoriesController#create as HTML Parameters: {"repository"=>{"is_default"=>"0", "url"=>"/web/dbtools/", "identifier"=>"dbtools", "extra_clone_url"=>"https://github.com/chenzhe07/dbtools"}, "utf8"=>"✓", "authenticity_token"=>"A6vO7Qnx/CYFrgo8bfOYI2ntc0VfJz96Z3dpjRk14m0=", "commit"=>"创建", "project_id"=>"manual", "repository_scm"=>"GitRemote"} Current user: chenzhe (id=5) Completed 500 Internal Server Error in 1179.1ms

NoMethodError (undefined method exists?' for Dir:Class): app/controllers/repositories_controller.rb:55:increate'

I have no idea for this error message, thanks a lot for your help.

Git <1.9 unable to fetch

From #1 reported by @spydmobile

To reproduce note that git 1.7 and 1.8 fail in these steps:

docker run -ti ubuntu:precise bash

apt-get update; apt-get install vim git


git --version
#    git version 1.7.9.5

mkdir /git; cd /git
git init --bare vagrant-vbox-snapshot
git --git-dir vagrant-vbox-snapshot/  remote add --tags --mirror=fetch origin https://github.com/dergachev/vagrant-vbox-snapshot.git
git --git-dir vagrant-vbox-snapshot/ remote -v
#      origin   https://github.com/dergachev/vagrant-vbox-snapshot.git (fetch)
#      origin   https://github.com/dergachev/vagrant-vbox-snapshot.git (push)

git  --git-dir vagrant-vbox-snapshot/ fetch --all  --verbose
#    Fetching origin
#    POST git-upload-pack (374 bytes)
#    remote: Counting objects: 206, done.
#    remote: Compressing objects: 100% (94/94), done.
#    Receiving objects: 100% (206/206), 32.67 KiB, done.
#    remote: Total 206 (delta 113), reused 203 (delta 112)
#    Resolving deltas: 100% (113/113), done.
#    From https://github.com/dergachev/vagrant-vbox-snapshot
#     * [new tag]         v0.0.2     -> v0.0.2
#     * [new tag]         v0.0.3     -> v0.0.3
#     * [new tag]         v0.0.4     -> v0.0.4
#     * [new tag]         v0.0.5     -> v0.0.5
#     * [new tag]         v0.0.6     -> v0.0.6
#     * [new tag]         v0.0.7     -> v0.0.7

#NB: if there were no tags, then this would have simply said "Fetching origin" and done nothing.

git --git-dir vagrant-vbox-snapshot/ log
#    fatal: bad default revision 'HEAD'

In git 1.9 the git log succeeds.

The problem was in this line:

git --git-dir vagrant-vbox-snapshot/  remote add --tags --mirror=fetch origin [email protected]:alexdergachev/test.git

That --tags adds tagopt = --tags field to git.config.remote.origin, which causes git to append --tags to git fetch --all, causing only tags (if they exist) to be fetched, thus superseding the --all flag behaviour to fetch all branches and tags (which is what we want). Interestingly git 1.7 and 1.8 have this problem, while 1.9 (which I'm running) seems to give --all precedence.

Potentially relevant: http://git.661346.n2.nabble.com/unclear-documentation-of-git-fetch-tags-option-and-tagopt-config-td7572964.html

Because in our plugin we always use git fetch --all, it seems we can safely drop the --tags from the remote add line, and things should work.

So simply dropping --tags fixes the problem:

rm -Rf vagrant-vbox-snapshot/
git init --bare vagrant-vbox-snapshot
git --git-dir vagrant-vbox-snapshot/  remote add --mirror=fetch origin https://github.com/dergachev/vagrant-vbox-snapshot.git

git  --git-dir vagrant-vbox-snapshot/ fetch --all  --verbose
#     * [new branch]      master     -> master
#     * [new branch]      no-vagrant-dependency -> no-vagrant-dependency
#     * [new branch]      refs/pull/14/head -> refs/pull/14/head
#     * [new branch]      refs/pull/14/merge -> refs/pull/14/merge
#     * [new branch]      refs/pull/18/head -> refs/pull/18/head
#     * [new branch]      refs/pull/22/head -> refs/pull/22/head
#     * [new branch]      refs/pull/23/head -> refs/pull/23/head
#     * [new branch]      refs/pull/6/head -> refs/pull/6/head
#     * [new branch]      refs/pull/6/merge -> refs/pull/6/merge
#     * [new tag]         v0.0.2     -> v0.0.2
#     * [new tag]         v0.0.3     -> v0.0.3
#     * [new tag]         v0.0.4     -> v0.0.4
#     * [new tag]         v0.0.5     -> v0.0.5
#     * [new tag]         v0.0.6     -> v0.0.6
#     * [new tag]         v0.0.7     -> v0.0.7

git --git-dir vagrant-vbox-snapshot/ log
#    SUCCESS

Is this plugin works with Redmine 3.2.1.stable ?

Dear Developpers,

Is this plugin works with Redmine : 3.2.1.stable

Environment:
  Redmine version                3.2.1.stable
  Ruby version                   2.3.1-p112 (2016-04-26) [x86_64-linux-gnu]
  Rails version                  4.2.6
  Environment                    production
SCM:
  Git                            2.7.4
  Filesystem             

Best Regards, Edouard Fazenda.

Store ssh keys for repository access

...in database and allow CRUD operations via redmine frontend.

Advantage: There is no need to access server where redmine is running on to add new 'deployment keys'/'access keys'.

Use relative path to known_hosts

I have redmine installed as a specific user: /home/my_redmine, and have Apache access (via Phusion Passenger) through symbolic link /var/www/my_redmine -> /home/my_redmine.
When I try to add repo I get: ssh-keygen: /var/www/.ssh/known_hosts: No such file or directory

Add Repository fail

In Add Repository page, I filled out Clone URL with my ssh form ( [email protected]:XXX/XXX.git )
But error occured saying,

"Clone URL [email protected]:XXX/XXX.git is not a valid remote."

But Redmine log said Completed 200 OK.

What can I try to solve this problem?

NoMethodError (undefined method `capture2' for Open3:Module)

I keep getting an error when I try to create a remot repository:

Parameters: {"repository_scm"=>"GitRemote", "authenticity_token"=>"TOKEN REMOVED", "project_id"=>"webadmin", "utf8"=>"â��", "repository"=>{"is_default"=>"1", "url"=>"", "identifier"=>"", "extra_clone_url"=>"[email protected]:jmuxfeldt/yii2_sandbox.git"}, "commit"=>"Create"}
Current user: admin (id=1)
NoMethodError (undefined method capture2' for Open3:Module): app/controllers/repositories_controller.rb:55:increate'

RUBY 1.8.7 REDMINE 2.6.0

Thank you but - Errno::EACCES in repositories on create

Sorry for creating an issue, wanted to say thank you this is going to make my life WAY easier - but cant get this to work

my project is on bitbucket, its private, my redmine VM has a deployment key in the bitbucket project.
When I tried to create it I got:

ERROR 500
Oops! You've found our error page
An error occurred on the page you were trying to access, a message has been sent to Redmine administrator. If you continue to experience problems please contact your Redmine administrator for assistance.

I run the redmine error monitor and it shows:

\

\

\

ALERT TYPE SOURCE ACTION MESSAGE USER PROJECT ISSUE #ERRS CREATED UPDATED BACKTRACE


Errno::EACCES repositories create Permission denied - /var/www/.ssh Franco Nogarin SPARCS - NWTFIRE 2 11 minutes 1 minute /usr/local/rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/fileutils.rb:245:in mkdir' /usr/local/rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/fileutils.rb:245:in fu_mkdir' /usr/local/rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/fileutils.rb:219:in `block (2 levels) in mkdir_p'

\

Support private bitbucket repositories

Given https://bitbucket.org/robertfausk/myrepo is a private bitbucket repository and I want to add it with redmine_git_remote.

Usage of clone URL [email protected]:robertfausk/myrepo.git is not working when project is private.
Flash message "Clone URL [email protected]:robertfausk/myrepo.git is not a valid remote." raises.

Usage of clone URL https://[email protected]/robertfausk/myrepo.git is not working when project is private.
Flash message "Clone URL https://[email protected]/robertfausk/myrepo.git is not a valid remote." raises. I suspect it's because of he tries to use user robertfausk but I only have enabled a access key in bitbucket config and enabled this one on my server for redmine user.

-b and --singlebranch support

for cases that the remote repo has lots of branches, but we only need one branch for project a, and another branch for project b, we should only clone the specific branch for specific project.

Clone URL is not a valid remote

Hi
i have two server :

  1. redmine (OS:Centos7)
  2. gitlab (OS:Centos7)

when i want create new repository in redmine's project , show below error :
Clone URL git@gitlabs:admin/myproject.git is not a valid remote.

i use ssh keygen :
when git clone by command in redmine server , show below error :

sh: git-upload-pack: command not found
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

please help me for my problem

Failed to create repo with Redmin 3.4.2.stable

My System:

Environment:
  Redmine version                3.4.2.stable
  Ruby version                   2.4.1-p111 (2017-03-22) [x86_64-linux]
  Rails version                  4.2.8
  Environment                    production
  Database adapter               Mysql2
SCM:
  Subversion                     1.8.10
  Mercurial                      3.1.2
  Bazaar                         2.7.0
  Git                            2.1.4
  Filesystem                     
  GitRemote                      2.1.4
Redmine plugins:
  redmine_changeauthor           1.0.1
  redmine_git_remote             0.0.1
  redmine_omniauth_google        0.0.1
  time_logger                    0.5.4

This used to work, but after upgrading redmine to 3.4.2.stable, I can no longer create new GitRemote repositories. When I do I get a crash report. The log says:

NoMethodError (undefined method `[]' for nil:NilClass):
  plugins/redmine_git_remote/app/models/repository/git_remote.rb:78:in `initialize_clone'
  app/controllers/repositories_controller.rb:46:in `create'
  lib/redmine/sudo_mode.rb:63:in `sudo_mode'

Looking further into it, it seems that Repository doesn't populate extra_info any more. I've added a debug log in git_remote.rb line 78, and attributes there contains:

... "login"=>"", "password"=>"", "root_url"=>"", "type"=>"Repository::GitRemote", 
"path_encoding"=>nil, "log_encoding"=>nil, "extra_info"=>nil, "identifier"=>"my-repo", 
"is_default"=>true, ...

Stop using insecure shell interpolation

I just pasted this as the clone URL by accident and submitted the repo creation form:

rsync -avq --chown=redmine:redmine /home/redmine/data/plugins/ /home/redmine/redmine/plugins/; supervisorctl restart unicorn

It executed quite fine and gave me this lovely message:

Clone URL rsync -avq --chown=redmine:redmine /home/redmine/data/plugins/ /home/redmine/redmine/plugins/; supervisorctl restart unicorn is not a valid remote.

Which implies it just executed potentially destructive code. Even aside from the obvious security hole, this has the potential to accidentally cause damage.

Auto "disable" repo, if can't connect via SSH

Hey Alex!

I've found a problem..

  1. I've migrated my redmine installation from one server to another
  2. I setup cron task on new one, to sync repos
  3. I didn't import all necessary keys in proper time (so I couldn't clone all repos)
    ..
    And I've got "abuse" warning from hosting, since my IP address is trying to "attack" some server.
    That was because of combination of cron task and incorrect setup of repository.

My suggestion is:

  1. Add "disabled" key into extra column hash (i meant disabled attribute to GitRemote class)
  2. Add "disabled" checkbox into settings
  3. mark any repository as "disabled" after first SSH fail (user can enable again at any time from settings - then it will check everything just like when creation new repo)

I think that's safer in term of "abuse" warnings.

What do you think?

migrate message (redmine 3.0.4)

plugins/redmine_git_remote/lib/redmine_git_remote/repositories_helper_patch.rb:10: warning: duplicated key at line 10 ignored: :required

fatal: bad default revision 'HEAD'

I installed redmine_git_remote and checkout a remote repository in redmine.
Then, I visited the /projects/my_project_name/repository page and got the "Internal Error" page.
I checked the path of the local repositories and saw the project's files there.
I try another 2 repositories and they all work well.
The error log of redmine shows:

App 9904 stdout: Calling fetch changesets on /opt/redmine-3.0.4-1/apps/redmine/htdocs/plugins/redmine_git_remote/repos/s003/fsbackend/fanshop-rest.git
App 9904 stdout: Fetching repo /opt/redmine-3.0.4-1/apps/redmine/htdocs/plugins/redmine_git_remote/repos/s003/fsbackend/fanshop-rest.git
App 9904 stdout: dc40e473079c7e657f81dcfd24585138ea210f80 refs/heads/master
App 9904 stdout: fcba1760adc8a608807f31f9d6fe3f4b67a3b9c2 refs/heads/testing
App 9904 stdout: Fetching origin
App 9904 stdout: dc40e473079c7e657f81dcfd24585138ea210f80 refs/heads/master
App 9904 stdout: fcba1760adc8a608807f31f9d6fe3f4b67a3b9c2 refs/heads/testing
App 9904 stdout: Initialized empty Git repository in /opt/redmine-3.0.4-1/apps/redmine/htdocs/plugins/redmine_git_remote/repos/s003/fsbackend/fanshop-rest/
App 9849 stderr: fatal: bad default revision 'HEAD'
App 9904 stdout: Calling fetch changesets on /opt/redmine-3.0.4-1/apps/redmine/htdocs/plugins/redmine_git_remote/repos/s003/fsbackend/fanshop-rest
App 9904 stdout: Fetching repo /opt/redmine-3.0.4-1/apps/redmine/htdocs/plugins/redmine_git_remote/repos/s003/fsbackend/fanshop-rest
App 9904 stdout: dc40e473079c7e657f81dcfd24585138ea210f80 refs/heads/master
App 9904 stdout: fcba1760adc8a608807f31f9d6fe3f4b67a3b9c2 refs/heads/testing
App 9904 stdout: Fetching origin
App 9849 stderr: From s003:fsbackend/fanshop-rest
App 9849 stderr: * [new branch] master -> master
App 9849 stderr: * [new branch] testing -> testing
App 9904 stdout: dc40e473079c7e657f81dcfd24585138ea210f80 refs/heads/master
App 9904 stdout: fcba1760adc8a608807f31f9d6fe3f4b67a3b9c2 refs/heads/testing
App 9904 stdout: dc40e473079c7e657f81dcfd24585138ea210f80 refs/heads/master
App 9904 stdout: fcba1760adc8a608807f31f9d6fe3f4b67a3b9c2 refs/heads/testing

fork error against windows server

I am trying to using the plugin against Redmine 3.3 on Windows server.

After I saved the setting of Clone URL for SSH, I got the Internal Error. Checking the Redmine log, it shows as following:

`Started GET "/redmine/projects/testproject/repositories/new?repository_scm=GitRemote" for 127.0.0.1 at 2017-09-08 09:47:07 +0800
Processing by RepositoriesController#new as JS
Parameters: {"repository_scm"=>"GitRemote", "project_id"=>"testproject"}
Current user: daichengbo (id=8)
Rendered repositories/_form.html.erb (2.0ms)
Rendered repositories/new.html.erb (3.0ms)
Rendered repositories/new.js.erb (4.0ms)
Completed 200 OK in 66ms (Views: 4.1ms | ActiveRecord: 56.0ms)
Started POST "/redmine/projects/testproject/repositories" for 127.0.0.1 at 2017-09-08 09:47:17 +0800
Processing by RepositoriesController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"DypRYb/ojQHHhjesW1/JhkAnNmgMZvPYRHTFLk5zk99YxuZaeUADcqyKU94vUtL+DGRbJLpUUYhEtW/2eaQwmQ==", "repository_scm"=>"GitRemote", "repository"=>{"is_default"=>"0", "identifier"=>"", "url"=>"", "extra_clone_url"=>"[email protected]:root/testproject.git"}, "commit"=>"创建", "project_id"=>"testproject"}
Current user: daichengbo (id=8)
Completed 500 Internal Server Error in 104ms (ActiveRecord: 85.0ms)

NotImplementedError (fork() function is unimplemented on this machine):
plugins/redmine_git_remote/lib/redmine_git_remote/poor_mans_capture3.rb:18:in fork' plugins/redmine_git_remote/lib/redmine_git_remote/poor_mans_capture3.rb:18:in capture3'
plugins/redmine_git_remote/lib/redmine_git_remote/poor_mans_capture3.rb:38:in capture2' plugins/redmine_git_remote/app/models/repository/git_remote.rb:160:in add_known_host'
plugins/redmine_git_remote/app/models/repository/git_remote.rb:94:in ensure_possibly_empty_clone_exists' plugins/redmine_git_remote/app/models/repository/git_remote.rb:84:in initialize_clone'
app/controllers/repositories_controller.rb:55:in create' lib/redmine/sudo_mode.rb:63:in sudo_mode'`

Clone URL is not a valid remote

I'm not sure what's going on here, but I think I have everything well configured and it does not work.

I've my nginx running with my own user and group (cirici:cirici):

$ head /etc/nginx/nginx.conf -n 1
user  cirici cirici;

Redmine's environment.rb file is also owned by cirici:cirici:

$ ls -lha /var/www/redmine/config/environment.rb
-rw-rw-r-- 1 cirici cirici 592 oct 21 21:13 /var/www/redmine/config/environment.rb

And if I try to do a git ls-remote -h [email protected]:group/project.git it works as expected:

$ git ls-remote -h [email protected]:oportunic/livinxop-android.git
cd29c08689784f89b2ff8d49a9b2070eee137230    refs/heads/develop
3b52a2e812421720c3a979d4c14262fb2cbe32fe    refs/heads/f/restyle
1db592795e47e7c6b4b0cdef0f568f5ef3a3a33f    refs/heads/master

But when I try to add the repo to redmine it says "Clone URL is not a valid remote"

captura de 2014-12-22 18 02 30

What am I doing wrong? 😢

PS. Forget that different URLs, the error says "http" and I'm trying to add "git@..." but forget it, I've tried both ways without success.

Error Handling when adding to known host fails

For Redmine 2.6, Ruby 2.0.0, Ubuntu 12.04

Completed 500 Internal Server Error in 17.4ms

NameError (undefined local variable or method `e' for #<Class:0x007f903f5245a0>):
  app/controllers/repositories_controller.rb:55:in `create'

The undefined is in git_remote.rb, line 168

rescue e

Could be replaced by

rescue Exception => e

I'd be happy to PR that later this week =)

What is the problem with repositories cleanup?

Thanks for good plugin,
I'm doing some minor fixies and I've noticed that in readme:

This plugin doesn't clean-up (delete) cloned repos from the file system when the record is deleted from Redmine.

And this in the code:

  # TODO: figure out how to do this safely (if at all)
  # before_deletion :rm_removed_repo
  # def rm_removed_repo
  #   if Repository.find_all_by_url(repo.url).length <= 1
  #     system "rm -Rf #{self.clone_path}"
  #   end
  # end

What was the reason for commenting this code out? I though if no Repository object with same URL is available, then it's safe to delete repo directory.. Is that right?

'Not a valid remote'

SCM GitRemote
Main Repository [x]
identifier testrepo
pathtorepository /usr/local/redmine/plugins/redmine_git_remote/repos/github.com/FreeBSD-RePerfect/freebsd
Clone URL https://github.com/FreeBSD-RePerfect/freebsd.git

'Clone URL https://github.com/FreeBSD-RePerfect/freebsd.git is not a valid remote.'

/usr/local/redmine/plugins/redmine_git_remote/repos/ is owned by redmine:redmine which is the user/group redmine is running as, I cannot find any other debug information, help? :)

running the latest: https://svn.redmine.org/redmine/branches/3.4-stable

Sanitize repository identifier

When adding ssh://[email protected]/evolvingweb/evolvingweb.ca-docker
the automatically generated identifier evolvingweb.ca-docker was not a valid redmine identifier (. is not allowed), needs to be sanitized to evolvingweb-ca-docker.

Are there other invalid characters to watch out for?

Invalid Git Command Format (on CentOS 6)

Recently stood up RedMine on a CentOS 6.6 AWS instance. Installed your plugin. When I attempt to add a GitHub-hosted remote, I get an error message indicating:

Clone URL Unable to run: git --git-dir /RedMine/repositories/git/Test remote add [email protected]:<USERID>/<PROJECT>.git

Dropped to the command-line and manually ran what the plugin is attempting to run and got a usage error from Git. In order to get Git to do the proper operation, I had to change the invocation to:

Clone URL Unable to run: git --git-dir=/RedMine/repositories/git/Test remote add origin [email protected]:<USERID>/<PROJECT>.git

Host OS: CentOS 6.6 (updated yesterday - 2015-05-28)
Git Version: 1.7.1 (from the git-1.7.1-3.el6_4.1.x86_64 found in the CentOS 6 standard repositories)

Should be noted that even though the command errors out, a prior operation does manage to create a skeleton directory at /RedMine/repositories/git/Test:

$ ls /RedMine/repositories/git/AMI6
branches  config  description  HEAD  hooks  info  objects  refs

Fields to include and use per project keys.

Hello Friend,

I tried this plugin with success on the latest version on the official docker image. Its amazing! But I figure that it would be nice if we had some fields to add the ssh keys and make a per-project configuration (using the deploy keys) ... What you think about it? Is it a valid enhancement?

NoMethodError (undefined method `[]' for nil:NilClass)

What's wrong:

`
Started POST "/projects/esignin/repositories" for 219.140.232.27 at 2018-04-23 15:16:14 +0800
Processing by RepositoriesController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"T3yW8k69j0TCwGthmsLfknRZqySKs2PksAKKY0/wcNfSjOMb54mT5s34vZHHZVyLDMVsE2yQwbpv4QaXSFqT/w==", "repository_scm"=>"GitRemote", "repository"=>{"is_default"=>"1", "identifier"=>"", "url"=>"", "extra_clone_url"=>"[email protected]:esignin.git"}, "commit"=>"创建", "project_id"=>"esignin"}
Current user: admin (id=1)
Completed 500 Internal Server Error in 164ms (ActiveRecord: 26.1ms)

NoMethodError (undefined method []' for nil:NilClass): plugins/redmine_git_remote/app/models/repository/git_remote.rb:80:in initialize_clone'
app/controllers/repositories_controller.rb:46:in create' lib/redmine/sudo_mode.rb:63:in sudo_mode'

`

"Fetch changesets automatically" initially displays 404 at project/ID/repository

Here's a minor bug:

To reproduce this bug with an existing repo:

  • remove its record from Redmine DB
  • remove its clone from the filesystem: rm -Rf plugins/redmine_git_remote/repos/github.com/dergachev/screengif/
  • follow steps above

Ruby 1.8 chokes on line breaks

Via #8: I have been getting a syntax error on
app/models/repository/git_remote.rb line 131:

ret[:path] = url
                    .gsub(/^.*:\/\//, '')    # Remove anything before ://
                    .gsub(/:/, '/')          # convert ":" to "/"
                    .gsub(/^.*@/, '')        # Remove anything before @
                    .gsub(/\.git$/, '')      # Remove trailing .git

Removing the line-breaks fixed this.

Improve README ssh key help

People seem to be confused about http:// vs [email protected] forms, explain about passwords and keys.
Explain the need to add create ~/.ssh/ or at least make sure the folder exists and is readable by the redmine user.

Related to #1

git remote does not show in choice of Scm

Hi
I use Redmine 4.0.3 bundled with Bitnami on Windows.
I sucessfully installed the plugin and it shows up in Administration --> Plugins (0.0.1 version)
But when i create a new project, under Repositories --> New repository --> SCM, i do not see Git remote.

is the plugin compatible with the 4.0.3 ? Any idea why it does not show ? (no error in Log)

Internal Server Error for SettingsController#index and AdminController#info

I cannot open the Administration->Settings nor the Administration->Information pages while this plugin is installed.

I use the official Redmine Docker image (https://hub.docker.com/_/redmine/), add the plugin (tag 0.0.2) via a bind-mount and the error starts happening directly after logging in for the first time.

Any suggestions? Thank you.

System information (without the plugin installed):

Environment:
  Redmine version                3.4.6.stable
  Ruby version                   2.4.4-p296 (2018-03-28) [x86_64-linux]
  Rails version                  4.2.8
  Environment                    production
  Database adapter               Mysql2
SCM:
  Subversion                     1.9.5
  Mercurial                      4.0
  Bazaar                         2.8.0
  Git                            2.11.0
  Filesystem                     

It also fails the same way for a sqlite3 database.

Detailed error log:

Started GET "/admin/info" for 10.0.1.4 at 2018-08-24 13:48:52 +0000
Processing by AdminController#info as HTML
  Current user: admin (id=1)
  Rendered admin/info.html.erb within layouts/admin (180.1ms)
Completed 500 Internal Server Error in 205ms (ActiveRecord: 7.5ms)

ActionView::Template::Error (uninitialized constant Repository::GitRemote):
    12: </table>
    13: <br />
    14: <div class="box">
    15: <pre><%= Redmine::Info.environment %></pre>
    16: </div>
    17:
    18: <% html_title(l(:label_information_plural)) -%>
  lib/redmine/info.rb:21:in `block in environment'
  lib/redmine/info.rb:20:in `each'
  lib/redmine/info.rb:20:in `environment'
  app/views/admin/info.html.erb:15:in `_app_views_admin_info_html_erb___2626609327580126895_70130347473760'
  lib/redmine/sudo_mode.rb:63:in `sudo_mode'

fork() not working on windows machines

Ruby does not provide fork() under windows. I worked arround that by replacing the call to fork() in line 18 of poor_mans_capture3.rb with Process.spawn(*cmd) and deleting line 23 (exec(*cmd)). As I'm not a ruby-programmer I don't know if this might introduce other problems. Are there any you could think of? Or is this a valid approach and you should use that instead of using fork()?

GitRemote does not fetch all branch

Using standard Git repo in Redmine, I can access to a repo (e.g http://redmine-root/projects/my-project/repository for default one) to fetch all branches (and change status for ticket depending on referencing keywords defined in http://redmine-root/settings?tab=repositories for all branches at once).

Using GitRemote, it only fetches current (master) branch so it does not change status of tickets referenced in dev branches. I have to access them directly ( http://redmine-root/projects/my-project/repository?rev=my-dev-branch ), one by one.

Is it the desired behaviour?

Thanks

Warning with redmine 3.4 during migrate task

Hello,

I've install your plugin and I migrate my server from 3.0.x to 3.4.x. Plugin still working, but I've a warning during migration task:

/home/redmine/redmine/plugins/redmine_git_remote/lib/redmine_git_remote/repositories_helper_patch.rb:10: warning: key :required is duplicated and overwritten on line 10

I've tried to resolved problem by myself, but I don't understand why redmine complaint about this. Hoping this plugin still active ?

Configuration:

Environment:
  Redmine version                3.4.2.stable
  Ruby version                   2.3.3-p222 (2016-11-21) [x86_64-linux]
  Rails version                  4.2.8
  Environment                    production
  Database adapter               Mysql2
SCM:
  Git                            2.7.4
  Filesystem                     
  GitRemote                      2.7.4
Redmine plugins:
  redmine_bootstrap_kit          0.2.3
  redmine_dmsf                   1.5.2
  redmine_git_remote             0.0.1
  redmine_jenkins                1.0.1
  redmine_ldap_sync              2.0.7.devel.g202f7c74b9
  redmine_my_page                0.1.10
  redmine_revision_branches      0.3.0
  redmineup_tags                 2.0.0

installl error

Docker container version Redmine:5

the error stack trace from Redmine docker container:

Your Gemfile lists the gem puma (>= 0) more than once.
You should probably keep only one of them.
Remove any duplicate entries and specify the gem only once.
While it's not a problem now, it could cause errors if you change the version of one of them later.
The Gemfile's dependencies are satisfied
rake aborted!
LoadError: cannot load such file -- redmine_git_remote/repositories_helper_patch
/usr/local/bundle/gems/zeitwerk-2.6.7/lib/zeitwerk/kernel.rb:38:in `require'
/usr/local/bundle/gems/zeitwerk-2.6.7/lib/zeitwerk/kernel.rb:38:in `require'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/dependencies/zeitwerk_integration.rb:51:in `require_dependency'
/usr/src/redmine/plugins/redmine_git_remote/init.rb:2:in `<top (required)>'
/usr/src/redmine/lib/redmine/plugin_loader.rb:31:in `load'
/usr/src/redmine/lib/redmine/plugin_loader.rb:31:in `run_initializer'
/usr/src/redmine/lib/redmine/plugin_loader.rb:108:in `each'
/usr/src/redmine/lib/redmine/plugin_loader.rb:108:in `block in load'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/callbacks.rb:427:in `instance_exec'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/callbacks.rb:427:in `block in make_lambda'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/callbacks.rb:198:in `block (2 levels) in halting'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/callbacks.rb:604:in `block (2 levels) in default_terminator'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/callbacks.rb:603:in `catch'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/callbacks.rb:603:in `block in default_terminator'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/callbacks.rb:199:in `block in halting'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/callbacks.rb:512:in `block in invoke_before'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/callbacks.rb:512:in `each'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/callbacks.rb:512:in `invoke_before'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/callbacks.rb:105:in `run_callbacks'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/reloader.rb:88:in `prepare!'
/usr/local/bundle/gems/railties-6.1.7.2/lib/rails/application/finisher.rb:124:in `block in <module:Finisher>'
/usr/local/bundle/gems/railties-6.1.7.2/lib/rails/initializable.rb:32:in `instance_exec'
/usr/local/bundle/gems/railties-6.1.7.2/lib/rails/initializable.rb:32:in `run'
/usr/local/bundle/gems/railties-6.1.7.2/lib/rails/initializable.rb:61:in `block in run_initializers'
/usr/local/bundle/gems/railties-6.1.7.2/lib/rails/initializable.rb:60:in `run_initializers'
/usr/local/bundle/gems/railties-6.1.7.2/lib/rails/application.rb:391:in `initialize!'
/usr/src/redmine/config/environment.rb:16:in `<top (required)>'
/usr/local/bundle/gems/zeitwerk-2.6.7/lib/zeitwerk/kernel.rb:38:in `require'
/usr/local/bundle/gems/zeitwerk-2.6.7/lib/zeitwerk/kernel.rb:38:in `require'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/dependencies.rb:332:in `block in require'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/dependencies.rb:299:in `load_dependency'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/dependencies.rb:332:in `require'
/usr/local/bundle/gems/railties-6.1.7.2/lib/rails/application.rb:367:in `require_environment!'
/usr/local/bundle/gems/railties-6.1.7.2/lib/rails/application.rb:533:in `block in run_tasks_blocks'
Tasks: TOP => db:migrate => db:load_config => environment
(See full trace by running task with --trace)
Your Gemfile lists the gem puma (>= 0) more than once.
You should probably keep only one of them.
Remove any duplicate entries and specify the gem only once.
While it's not a problem now, it could cause errors if you change the version of one of them later.
The Gemfile's dependencies are satisfied
rake aborted!
LoadError: cannot load such file -- redmine_git_remote/repositories_helper_patch
/usr/local/bundle/gems/zeitwerk-2.6.7/lib/zeitwerk/kernel.rb:38:in `require'
/usr/local/bundle/gems/zeitwerk-2.6.7/lib/zeitwerk/kernel.rb:38:in `require'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/dependencies/zeitwerk_integration.rb:51:in `require_dependency'
/usr/src/redmine/plugins/redmine_git_remote/init.rb:2:in `<top (required)>'
/usr/src/redmine/lib/redmine/plugin_loader.rb:31:in `load'
/usr/src/redmine/lib/redmine/plugin_loader.rb:31:in `run_initializer'
/usr/src/redmine/lib/redmine/plugin_loader.rb:108:in `each'
/usr/src/redmine/lib/redmine/plugin_loader.rb:108:in `block in load'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/callbacks.rb:427:in `instance_exec'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/callbacks.rb:427:in `block in make_lambda'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/callbacks.rb:198:in `block (2 levels) in halting'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/callbacks.rb:604:in `block (2 levels) in default_terminator'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/callbacks.rb:603:in `catch'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/callbacks.rb:603:in `block in default_terminator'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/callbacks.rb:199:in `block in halting'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/callbacks.rb:512:in `block in invoke_before'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/callbacks.rb:512:in `each'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/callbacks.rb:512:in `invoke_before'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/callbacks.rb:105:in `run_callbacks'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/reloader.rb:88:in `prepare!'
/usr/local/bundle/gems/railties-6.1.7.2/lib/rails/application/finisher.rb:124:in `block in <module:Finisher>'
/usr/local/bundle/gems/railties-6.1.7.2/lib/rails/initializable.rb:32:in `instance_exec'
/usr/local/bundle/gems/railties-6.1.7.2/lib/rails/initializable.rb:32:in `run'
/usr/local/bundle/gems/railties-6.1.7.2/lib/rails/initializable.rb:61:in `block in run_initializers'
/usr/local/bundle/gems/railties-6.1.7.2/lib/rails/initializable.rb:60:in `run_initializers'
/usr/local/bundle/gems/railties-6.1.7.2/lib/rails/application.rb:391:in `initialize!'
/usr/src/redmine/config/environment.rb:16:in `<top (required)>'
/usr/local/bundle/gems/zeitwerk-2.6.7/lib/zeitwerk/kernel.rb:38:in `require'
/usr/local/bundle/gems/zeitwerk-2.6.7/lib/zeitwerk/kernel.rb:38:in `require'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/dependencies.rb:332:in `block in require'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/dependencies.rb:299:in `load_dependency'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/dependencies.rb:332:in `require'
/usr/local/bundle/gems/railties-6.1.7.2/lib/rails/application.rb:367:in `require_environment!'
/usr/local/bundle/gems/railties-6.1.7.2/lib/rails/application.rb:533:in `block in run_tasks_blocks'
Tasks: TOP => db:migrate => db:load_config => environment
(See full trace by running task with --trace)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.