Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Subversive » precommit hook client side
precommit hook client side [message #553544] Tue, 17 August 2010 21:50 Go to next message
sasha is currently offline sashaFriend
Messages: 58
Registered: July 2009
Member
We are trying to execute some style ckecks before a commit and cannot put
this into the subversion server side hooks because this is for a subteam. Is
there any way to associate some precommit hooks on the client side ?
thanks
sasha
Re: precommit hook client side [message #553648 is a reply to message #553544] Wed, 18 August 2010 10:27 Go to previous messageGo to next message
olly2 Mising name is currently offline olly2 Mising nameFriend
Messages: 27
Registered: June 2010
Junior Member
Hello Sasha,
to answer you question directly: no, it is not possible.

To make some suggestions how you could solve your problem using subversion:


  1. Include the style check in your make/build enviroment.
    If you have some kind of build system (nightly build, a Hudson server, a make file, Ant Tasks ....) use this to generate the necessary checks into a report including somethink like an overall report. I would suggest an appraoch like this:


    • when working on the trunk deviations are allowed
    • when creating a release branch (you may find some nomenclature for the naming of branches helpful in this case Smile ) deviations to the code styling rules are no longer allowed and an email is send in this case to the team including the deviation report. If you have a nightly build you can add this task there.
    • when creasting a baseline (using a tag, again you should introduce naming conventions for tags) and there is still a deviation this is reported to some QA or Management persons, e.g by mail.


  2. Use a intelligent pre commit hook.
    You can get some information about the commit in your pre commit hook including the repository path where the commit is happening. Just check this path and then perform your checks depending on this results.


In my opinion there is no need to introduce a client site pre commit hook, and from a conceptional point of view I think this is difficult and not stabel. So, think over your development process. Where could this check be implemented? And try to give yourselfe a NOT TECHNICAL TOOL answer! When you know this then think of an efficient technical solution.

Sorry for this epical answer but as a process person in my company it is very difficult for me not to think in this direction - so my answers are sometimes a little like "have a look to the whole thing" .. Sorry .. Laughing

Best regards,
Olaf
Re: precommit hook client side [message #554032 is a reply to message #553648] Thu, 19 August 2010 18:43 Go to previous messageGo to next message
sasha is currently offline sashaFriend
Messages: 58
Registered: July 2009
Member
Hello Olly,
Thankyou for your insights. My problem is that we have a RM team that
manages the nightly builds for multiple teams and the SVN repo. My team is
just one of their clients so I really cannot enforce any process in their
team. I just want to make sure that my team's standards are enforced
somewhat.
The problems : a) I cannot change processes in RM team b) I dont have access
to svn server side hooks

I will have checkstyle target in the ant build, but there is no way to
enforce that the dev will run the target and the the code that is going to
be checked in conforms to the standards. Hence the client side pre-commit
hook idea because we use subversive plugin to checkin

I found that subversion does offer some kind of wat to write an commit
extension to the plugin- as you say its a maintenence nightmare.

I wish subversion would provide some pre-built commit extensions
customizable via xml configurations or some such

Thanks
Sasha
Re: precommit hook client side [message #1726585 is a reply to message #553544] Mon, 14 March 2016 20:36 Go to previous messageGo to next message
Stefan Zugal is currently offline Stefan ZugalFriend
Messages: 7
Registered: October 2014
Junior Member
For the record: we were also looking for a pre-commit hook for SVN. What we did is to use extension point "org.eclipse.team.svn.ui.commit". You can easily implement a pre-commit hook in the following way:

public class CommitActionFactory extends DefaultCommitActionFactory {

	@Override
	public ICommitDialog getCommitDialog(final Shell shell, Collection allFilesToCommit,
			final ICommentDialogPanel commentPanel) {
		return new ICommitDialog() {
			public String getMessage() {
				return commentPanel.getMessage();
			}

			public int open() {
				boolean isCommitValid = performSomeValidation();
				if (!isCommitValid) {
					return DefaultDialog.DIALOG_FAILED;
				}

				return new DefaultDialog(shell, commentPanel).open();
			}
		};
	}
}


If you return DefaultDialog.DIALOG_FAILED from the method open (see above), the commit dialog will not show up at all. Regarding the "maintenance nightmare": you can easily set up an update site to roll out your updates.
Re: precommit hook client side [message #1761406 is a reply to message #1726585] Wed, 10 May 2017 16:10 Go to previous message
Aruna Chen is currently offline Aruna ChenFriend
Messages: 1
Registered: May 2017
Junior Member
I am using eclipse-SDK Mars(4.5) Plug-in development environment to create the plugin, and then install the plug-in in the Eclipse IDE for Developers Mars(4.5.2) through the dropins directory in eclipse folder.

I have tried to implement the precommit-hook for SVN using the above code to extend the DefaultCommitActionFactory, and returns DefaultDialog.DIALOG_FAILED; statement, but after I install my plugin and test ( by right click file and team->commit ), the commit Dialog shows up as usual, and allows me to commit changes to the svn repo.

I have also tried to implement the class ICommitActionFactory interface, but still couldn't prevent the commit dialog from showing up.

I know the plugin is installed properly, so I don't know why the method for commit dialog is not being overridden by my plugin.

here is my code, any help with this will be appreciated!

package testtwo;

import java.util.Collection;

import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.svn.core.operation.CompositeOperation;
import org.eclipse.team.svn.core.operation.IActionOperation;
import org.eclipse.team.svn.core.operation.IRevisionProvider;
import org.eclipse.team.svn.ui.dialog.DefaultDialog;
import org.eclipse.team.svn.ui.extension.factory.ICommentDialogPanel;
import org.eclipse.team.svn.ui.extension.factory.ICommitActionFactory;
import org.eclipse.team.svn.ui.extension.factory.ICommitDialog;
import org.eclipse.team.svn.ui.extension.impl.DefaultCommitActionFactory;
import org.eclipse.ui.IWorkbenchPart;
public class CommitActionFactory1 extends DefaultCommitActionFactory {

@Override
public ICommitDialog getCommitDialog(final Shell shell, Collection allFilesToCommit,
final ICommentDialogPanel commentPanel) {
return new ICommitDialog() {
public String getMessage() {
return commentPanel.getMessage();
}

public int open() {
boolean isCommitValid = performSomeValidation();
if (!isCommitValid) {
return DefaultDialog.DIALOG_FAILED;
}

return new DefaultDialog(shell, commentPanel).open();
}

private boolean performSomeValidation() {
// TODO Auto-generated method stub
return false;
}
};
}
}
Previous Topic:resource does not exist in the HEAD revision of the repository
Next Topic:Errors while offline
Goto Forum:
  


Current Time: Fri Apr 19 08:06:56 GMT 2024

Powered by FUDForum. Page generated in 0.01957 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top