Project

General

Profile

Refresh repository in Redmine after editing commit message

Added by Anonymous about 14 years ago

How can I refresh my repository after I edited one of my commit messages ? I can see that the commit message has changed by using svn log but I'm still seeing the old message in Redmine. Thanks in advance


Replies (10)

RE: Refresh repository in Redmine after editing commit message - Added by Anonymous about 14 years ago

Forgot to add this:

Ruby version 1.8.7 (i486-linux)
RubyGems version 1.3.6
Rack version 1.0
Rails version 2.3.5
Active Record version 2.3.5
Active Resource version 2.3.5
Action Mailer version 2.3.5
Active Support version 2.3.5
Application root /opt/redmine
Environment production
Database adapter mysql
Database schema version 20100313171051

RE: Refresh repository in Redmine after editing commit message - Added by Felix Schäfer about 14 years ago

AFAIK, the SCM adapters in redmine consider things past to be immutable, i.e. I don't think you can force redmine to reread old commits. The obvious workaround is to delete the SCM in the project's preferences and add it again, causing redmine to reread the whole repository's history.

RE: Refresh repository in Redmine after editing commit message - Added by Daniel Drucker about 10 years ago

Unfortunately, if you do that you lose all associations between revisions and tickets. Is there any way around that?

RE: Refresh repository in Redmine after editing commit message - Added by Daniele Pedroni about 10 years ago

I don't think you're losing associations... I'd say, the opposite: Redmine will fetch the repository log once again, so if you modified some comments to add associations you forgot while committing, they will be introduced.

I did it a few weeks ago: it's time and resource consuming (20k revisions SVN repo and 300 issues Redmine instance took about 20 minutes with Redmine not accessible), but it's not going to break anything, IMHO.

RE: Refresh repository in Redmine after editing commit message - Added by Daniel Drucker about 10 years ago

Re-fetching the log will add associations which live in commit messages, but will remove associations which were added through the redmine web interface.

RE: Refresh repository in Redmine after editing commit message - Added by Daniele Pedroni about 10 years ago

I'm not sure to understand what you mean with "added through redmine web interface", could you please provide an example?
thank you

RE: Refresh repository in Redmine after editing commit message - Added by Daniel Drucker about 10 years ago

See attached screenshots.

s1.png (139 KB) s1.png screenshot 1
s2.png (153 KB) s2.png screenshot 2

RE: Refresh repository in Redmine after editing commit message - Added by Daniele Pedroni about 10 years ago

Thanks a lot, hard to admit, but I didn't know this really useful feature! Then, now I understand your point and I think you're right, no way to retrieve the information you lose once you disconnect Redmine from repository to rescan log messsages.

That's why I'll continue working like this: if someone forgets to add the connection between issue and commit, I prefer to edit the SVN repo log message and then, time to time, rescan the entire repository disconnecting and reconnecting it. I know it's not a "clean" practice but it is acceptable for our business.

Thank you again for the tip.

RE: Refresh repository in Redmine after editing commit message - Added by Mattthew von Arx about 7 years ago

I know this is 3 years old, but it was bothering me. I have a complex project with over 30 associated repositories, and didn't want to go through and delete and re-create everything. I am running Redmine 2.5.2.stable.13339, so your mileage may vary with these instructions...

So here it goes, how to bulk force refresh repositories. To start off with, Redmine doesn't keep a copy of the repository locally, it instead parses history, and stores that information in four different places. The first place is 'changesets_issues' which associates your changes with Redmine issues, the next is 'changes' which describe discrete file changes, then there is 'changesets' which are the individual commits, and finally the 'repositories' table gets updated with the most recent revision reference (think version number for SVN, and hash for Git). In order to force refresh your database links, you have to clear out all of this history, and reset a specific term in the 'repositories' table. As I am using Git, some of my queries are tailored to that repository type selection.

First, you need to access the sql database...

mysql --user=<username> --password=<password> redmine

If you are using time recording, you wil need to start by deleting time entries associated with the commits that are about to be removed...

delete from time_entries where id in(select distinct T.id from time_entries T inner join (select revision from changesets where repository_id in(select id from repositories where type='Repository::Git')) C on T.comments like concat(concat('%', C.revision),'%'));

Then, you will first delete the 'changesets_issues' and 'changes' table entries as they reference the 'changesets' table...

delete from changesets_issues where changeset_id in(select id from changesets where repository_id in(select id from repositories where type='Repository::Git'));
delete from changes where changeset_id in(select id from changesets where repository_id in(select id from repositories where type='Repository::Git'));

You then delete the associated 'changesets' entries...

delete from changesets where repository_id in(select id from repositories where type='Repository::Git');

Then you update the repositories extra info field (this maintains a reference of the most recent recorded commit, if you don't clear it, it will only re-import new commits)

update repositories set extra_info = '' where type='Repository::Git';

You can then quit mysql, and navigate to the redmine install directory.

Now force a refresh of the repositories to rebuild your database...

ruby ./script/rails runner "Repository.fetch_changesets" -e production

RE: Refresh repository in Redmine after editing commit message - Added by Aleksandar Pavic almost 5 years ago

FYI, I have edited wrong svn refID for one developer, first have him change text via [[https://stackoverflow.com/a/1015407/800965]]

then just edited his commit in changesets table, and changed issue_id in changesets_issues.

    (1-10/10)