Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin fails with post 1.3.0 Redmine: Code included to fix (backward compatible) #136

Open
wants to merge 110 commits into
base: master
Choose a base branch
from

Conversation

kubitron
Copy link

There are three problems that have arisen with running redmine_git_hosting on the 1.3-stable branch of Redmine (DO NOT PULL THE TRUNK -- IT IS HAS A PARTIALLY IMPLEMENTED FEATURE THAT WILL REALLY BREAK THIS PLUGIN AS IT CURRENTLY EXISTS):

  1. The developers have removed the TabularFormBuilder, thus breaking several views
  2. The developers have deprecated (for removal in 1.5) labelled_tabular_form_builder, which will break several views.
  3. The developers have removed the generic :controller/:action/:id route at the bottom of routes.rb, thereby breaking the edit/delete functions for gitolite keys.

This pull request fixes these problems (and cleans up the gitolite-key editing functionality in the process). Note that it is referenced off my master branch, which provides a bunch of other benefits in stability (includes the Resilience patches discussed in #124). If there is sufficient interest to somehow factor it back to the current redmine_git_hosting master, I will consider requests... Incidentally, I believe that this fix should be backward compatible with earlier versions of Redmine (that is my intention!). Let me know if it is not true (at least works with 1.2.2, and should work with at minimum 1.0, but...)

--EDIT 1/12/2012 --
With latest commit (00aa93d), now export user keys to administrator off the user/edit page, also fixed slight security flaw.

-- Edit 1/16/2012 --
One additional commit (0740c23) will resync the hooks parameters on a fetch_changesets, making sure that the update keys don't get out of sync. This is really a part of the resilience branch (which underlies this set of commits).

It is very important to execute a db:migrate_plugins after installing this, since the other commits on which it depends have introduced new plugin options. Thus, make sure to do:

rake db:migrate_plugins RAILS_ENV=production

Please get back to me with any bugs.

This prevents a rediculous number of calls to update_repositories
caused by the fact that redmine saves to the repository model for
every commit that it examines.  This patch also prevents multiple
calls to update_repositories when adding groups to the membership
of a project.

You need to migrate plugins to take advantage of new indices:

	rake db:migrate_plugins
This patch should remove all remaining need for recursive calls to update_repositories.
Will log such calls as errors in upcoming major code fix...
The primary "update_repositories" function is now largely self-correcting
against a variety of errors seen in the field.  Also added a bunch of
error checking on functions called-out to the shell.  Among other things,
this code attempts to reconnect the gitolite-admin public key when it
gets deleted (can happen).

Regular use of 'sys/fetch_changesets' will recorrect any errors in the
public key directory and gitolite.conf file. For example, orphan keys
that happen to be left behind in the public key directory will be removed,
missing keys will be added, etc.

One new piece of functionality is the 'recycle_bin' which is used to store
deleted repositories immediately after they are deleted (allowing them
to be recovered for up to 'gitRecycleExpireTime' hours after deletion).

You need to migrate plugins because there are new plugin settings:

    rake db:migrate_plugins
This is not a major issue (or even correctness issue), but will cause
complaints of recursion in the log.
change rakefile to install binary policy (redmine_git.pp) instead of
compiling source policy (redmine_git.te) before every
installation. New rake task added to recompile policy if necessary:

    rake selinux:redmine_git_hosting:build_policy
@kubitron
Copy link
Author

Sorry, all. I accidentally pushed a bug into the second-to-last commit. Fixed through history editing (bad idea, I know, trying to keep packaging simple, should these commits ever be merged into the main branch.

Just kill of last two commits and repull.

Would love comments from others on this latest commit. This commit will be the last in this resilience branch (promise), assuming that it works for people.

Any of the old lurkers still out there? bakerjonas? simonsd? Willing to try this new commit?

@simonsd
Copy link

simonsd commented Jan 10, 2012

Sorry, running this in beta for my company's internal infra right now.
Don't really feel like breaking it atm.

I am however planning on setting up a new vm tomorrow for testing purposes, might test the patch there.
For now I'll stick to running 1.2.1, might try out migration to 1.3.x later on.
I'll keep you informed :)

@kubitron
Copy link
Author

Actually, this fix is only compatible with 1.3x -- doesn't need to use it. Should work find with 1.2.1!

(And have other benefits!). I'm more interested in the previous commits anyway... They continue the fixes that you liked on my resilience pull request (#124).

kubitron and others added 21 commits January 10, 2012 23:15
It is important to remember to migrate_plugin settings, since there
are new settings and one setting has changed a bit (i.e. httpServer
should nolonger include a rails_root path).  Thus, make sure to:

    rake db:migrate_plugins

This commit includes a number of changes.  First and foremost, the
update_repositories() function now handles deletes and repository
moves as well as all other changes.  Consequently, :RESYNC_ALL will be
able to recover from a variety of problems involving movement of
repositories resulting from project parent changes.  Note that changes
in the parent for a subtree of projects works much better than before.

Second, this commit adds new settings which allow (1) redmine-managed
repositories to be focused in a specific subdirectory of the gitolite
repository, (2) allow repositories to be named either hierarchically
(default) or concentrated in a single directory (flat) independent of
project parents, and (3) an extra path parameter which can be added to
the http URL for smart http access of repositories.

Third, added the "access" box at the top of the settings page which
shows explicitly how settings affect access parameters.

Random improvements include (1) rewrite of routes for smart HTTP to
better handle changes in parentage (and avoid need to change routes as
project parents change); (2) changes in settings now immediately
trigger resulting changes in state (before, the settings cache got in
the way); (3) all of the path functions (repository positions, ssh
access, http access) have been concentrated into a small number of
functions at the top of git_hosting.rb, rather than spread throughout
the code; (4) continuing the changes started with the original
performance fixes, cleaned up observer behavior triggered by changes
in project membership and settings.
First, altered views to correct for the fact that (1) TabularFormBuilder
was removed and (2) labelled_tabular_form_for was deprecated.  To allow
this new code to work with pre 1.3.1 versions of Redmine, added an
app/helpers/application_helper.rb which defines the new accepted
helpers if they are not already defined.

Second, made the gitolite_public_keys controller a bit more RESTful in
response to the removal of the generic :controller/:method/:id route.
Note that without these changes, get weird failures around the /my/account
sidebar.  Now, everything happens on the /my/account page: Does not use
separate screen for key edit, and removed the confusion "active" checkbox
on edit (given recent fixes, this is only a weird way to delete key).  Finally,
this code asks for confirmation before deleting a key.  Note that account.rhtml
updated slightly (has password icon now near "change password").
This commit refactors the gitolite-public-key view to (1) remove
MVC violations (i.e. move the DB access into respective controllers,
(2) separate the view/edit functionality into a separate partial so
that (3) it can be called from the user edit screen.  As a result,
the administrator can now look at and edit user's keys (which I have
found is necessary for some clueless users).  The previous commit
would allow someone to view other public keys (but not edit them!); this
commit fixes this flaw.

Also, updated the style of the display to better reflect the 1.3+
style of redmine.  This code is still backward compatible with
earlier versions of redmine.  Also, moved .rhtml => .html.erb in
preparation for Rails 3.0 (rest of Redmine alreday updated)
…now reported. Removed extra cruft in error reporting.
use with smart HTTP, even when usernames include illegal characters
such as '@'. For example, usernames such as "John@Doe" => "John%40Doe"
in the URL box.
Fixed some stray colons that broke ChiliProject 3.0 on Ruby 1.9.2-p290.
According to gcymbalski, ChiliProject is 3.0 is now functional.
repository access methods for new repositories (i.e. for daemon, HTTP,
and CIA notification). Finally, added more rake tasks to ease
maintenance (in the :redmine_git_hosting namespace). Update README
with information about these new options and with with new
compatibility information.

Since there are 5 new settings, make sure to migrate plugins again:

    rake db:migrate_plugins RAILS_ENV=xxx
directory, thereby (hopefully) avoiding confusion about this
directory. Give options for making scripts read-only if desired. Small
updates to settings logic to better support this installation flow.
this by changing the access mechanism to automatically construct a
git_repository_extra structure if it is missing.
removed as project and repository permissions change. Also, when
projects are not public, the git-daemon selection box on the
repository page is disabled (to make it clearer that non-public
projects cannot be exported by the git daemon).
Several changes here: (1) if failed to merge changes, try deleting and
recloning before doing something more drastic.  (2) Try to fixup admin
key by using direct cloning of admin repo and pushing of changes via
gl-admin-push; fallback to gl-setup only if gl-admin-push doesn't
exist.  (3) When reinstalling admin key, try to keep admin key name
from conf file (if exists) or keydir (if there is a matching key to
remine's key).  (4) Finally make sure to remove any keys from keydir
that match redmine's key before reinstalling key -- to avoid name
conflicts on access.
of project should have triggered removal of user's keys from the
keydir.
This problem likely introduced by earlier fix to mirror error reporting.
labelled_form_for and labelled_remote_form_for: do not do so if
lib/tabular_form_builder.rb undefined!
kubitron and others added 30 commits September 26, 2012 11:40
This is a feature release which provides compatibility with Redmine 1.4.

It also includes a few bug fixes.  See release notes at:
https://github.com/kubitron/redmine_git_hosting/wiki/Release-Notes
…ither array of strings or symbols depending on version of Ruby.
This is a bug-fix release to restore compatibility with Redmine < 1.4
and with Ruby 1.9.x.  See release notes at:

    https://github.com/kubitron/redmine_git_hosting/wiki/_history
2011072600000_extend_changesets_notified_cia.rb tries to delete
notified_cia column in changesets table, but
2011081700000_move_notified_cia_to_git_cia_notifications.rb deletes
notified_cia column before it does, so an error occurs.

A solution is to let 2011072600000_extend_changesets_notified_cia.rb
remove notified_cia column only if the column exists.
Remove unneeded whitespace in gitolite config comment
This fix involves the key repair code as well as the configuration file
handling code (to maintain multiple administrative keys).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants