Is there any way that I can force a tool, like NArrange, to run during the pre-checkin process (or other validation apps for that matter like StyleCop). Subversion had hooks for pre-checkin and post-checkin and I'm sure that Fortress has something similar I just can't seem to find where the tie-in is. I've got CC.NET setup to run my post-build tools (like FxCop, NUnit, and NCover) but I would like a way to modify a file being checked in or to reject a check in based on a file not following coding standards. Can anyone point me in the right direction?
Regards
NArrange on check-in
Moderator: SourceGear
Re: NArrange on check-in
We don't currently have that functionality. I can take a feature request if you'd like.
In the meantime what one could do is either use the client API to create a small tool for check-ins that could run the tool you want as well, or write a script with the command-line that would be used for check-ins, but kick off the second tool before actually performing the check-in.
F: 15382
In the meantime what one could do is either use the client API to create a small tool for check-ins that could run the tool you want as well, or write a script with the command-line that would be used for check-ins, but kick off the second tool before actually performing the check-in.
F: 15382
Beth Kieler
SourceGear Technical Support
SourceGear Technical Support
Re: NArrange on check-in
I would like to add we also would be very interested in having this functionality. I would find it especially helpful because NArrange would maintain a controlled order of the code, which allows a better blame history of what actually changed, was added and removed, as opposed to just moving functions around during refactoring. Please notify us if this will become an item and if so when it will be released.
Thanks,
Jason Seidell
Infinedi
Thanks,
Jason Seidell
Infinedi
Re: NArrange on check-in
Just as a follow up I did find a work around. In Visual Studio you can write macros that automatically fire when IDE events happen.
To create a macro to automatically NArrange everytime a file is saved.
1) Go to 'Tools' -> 'Macros' -> 'Macros IDE ...'
2) From the macro IDE editor Select 'MyMacros' and open the 'EnvironmentEvents'
3) Select the 'DocumentEvents' and 'DocumentSaved' event to generate custom code for the IDE document save event.
4) Insert code to run NArrange against the currently saved file:
Obviously change the paths above to your machine, environment, and config file path.
Ideally I would rather pull the NArrange executable path and arguments from the registry that way we can script updating the paths across all development machines, but for right now this gets it up and running. The /c option tells NArrange to use a common configuration file that our senior programmers maintain so all the developers are NArranging to the same standard.
5) Save the changes and close the MacroIDE, restart Visual Studio and you should be good to go. I have it setup to show me the NArrange console window so I know it's working and to wait until NArrange completes or 1 second per file. Since I just started doing this I'm not sure if this will be a pain or annoyance, but I want to see it working at least for now.
6) I changed the Visual Studio options to 'Auto-load changes, if saved' (under Options -> Environment -> Documents) so it will automatically reload if NArrange updated the file instead of prompting me for the change.
I tested with Fortress, creating new files, and doing a check-in before saving and didn't really encounter any problems, except if I modify a file then undo check out, and then modify the file again Visual Studio sometimes misses the change to the file on disk and prompts whether to keep your changes or reload the file from disk. If you get this pop-up and don't pay attention and click to reload from disk you will lose whatever change you just made, however since this pops up as soon as you make the first change to the file you will only lose a few keystrokes when it reloads.
Ideally I would still rather see this as an option on the Fortress/Vault server so I don't have to make sure all the developers are running this setup and pointing to the correct config file, etc. to maintain diff consitency of our files and showing true code changes, not just refactoring and moving code around.
Hope someone else finds this handy.
Jason
Link to MSDN documentation for IDE Events that macros can tie to: http://msdn.microsoft.com/en-us/library ... s.80).aspx
To create a macro to automatically NArrange everytime a file is saved.
1) Go to 'Tools' -> 'Macros' -> 'Macros IDE ...'
2) From the macro IDE editor Select 'MyMacros' and open the 'EnvironmentEvents'
3) Select the 'DocumentEvents' and 'DocumentSaved' event to generate custom code for the IDE document save event.
4) Insert code to run NArrange against the currently saved file:
Code: Select all
Const NarrangeExePath As String = "C:\Program Files (x86)\NArrange 0.2.8\narrange-console.exe"
Const NarrangeArgs As String = """/c:R:\ediexe\NArrangeConfig.xml"" {0}"
Shell(NarrangeExePath & " " & String.Format(NarrangeArgs, Document.FullName), AppWinStyle.NormalFocus, True, 1000)
Ideally I would rather pull the NArrange executable path and arguments from the registry that way we can script updating the paths across all development machines, but for right now this gets it up and running. The /c option tells NArrange to use a common configuration file that our senior programmers maintain so all the developers are NArranging to the same standard.
5) Save the changes and close the MacroIDE, restart Visual Studio and you should be good to go. I have it setup to show me the NArrange console window so I know it's working and to wait until NArrange completes or 1 second per file. Since I just started doing this I'm not sure if this will be a pain or annoyance, but I want to see it working at least for now.
6) I changed the Visual Studio options to 'Auto-load changes, if saved' (under Options -> Environment -> Documents) so it will automatically reload if NArrange updated the file instead of prompting me for the change.
I tested with Fortress, creating new files, and doing a check-in before saving and didn't really encounter any problems, except if I modify a file then undo check out, and then modify the file again Visual Studio sometimes misses the change to the file on disk and prompts whether to keep your changes or reload the file from disk. If you get this pop-up and don't pay attention and click to reload from disk you will lose whatever change you just made, however since this pops up as soon as you make the first change to the file you will only lose a few keystrokes when it reloads.
Ideally I would still rather see this as an option on the Fortress/Vault server so I don't have to make sure all the developers are running this setup and pointing to the correct config file, etc. to maintain diff consitency of our files and showing true code changes, not just refactoring and moving code around.
Hope someone else finds this handy.
Jason
Link to MSDN documentation for IDE Events that macros can tie to: http://msdn.microsoft.com/en-us/library ... s.80).aspx
Re: NArrange on check-in
Thank you for the update. Posting the information is appreciated.
Beth Kieler
SourceGear Technical Support
SourceGear Technical Support