Corey Trager of BugTracker.NET has sent this vbs script below which can be enhanced to integrate SVN and BugTracker. It grabs entries from SVN when files are committed and posts to the database that BugTracker.Net uses.

I didn't want this code to be lost in comments and copied here with formatting.

Thanks very much Corey.

 

option explicit
' HOW TO USE THIS SCRIPT

' This script is a Subversion "post-commit hook".
' To execute this script first create a file in your repository hooks folder
' called "post-commit.bat".

' Put just one line in the .bat file which will point to this script.
' c:\somewhere\btnet_post_commit.vbs %1 %2

' Put this script where the .bat file is pointing to, and then edit the
' lines below.

' Change this line so that it's the path to your Subversion\bin\svnlook.exe
dim svnlook_path
svnlook_path = """c:\program files\subversion\bin\svnlook"""

' Change the database connection string here.
' This is NOT the same as the one in web.config. Web.config is using ADO.NET.
' This one is using plain old ADO.
dim connection_string
connection_string = "Provider=SQLOLEDB; Data Source=(local); Initial Catalog=btnet; User ID=sa; Password=;"

dim temp_file
temp_file = "C:\temp\btnet_svntemp.txt"

' END OF THE PARTS YOU HAVE TO CHANGE. THE REST SHOULD BE OK

dim repos
dim rev
repos = wscript.arguments(0)
rev = wscript.arguments(1)
' repos = "c:\cit\svnrepos" for testing
' rev = 12 for testing

dim shell
set shell = WScript.Createobject("WScript.Shell")

dim cmd
dim results_object
dim log_string
dim changed_string

' run the svnlook log command
cmd = svnlook_path & " log -r " & rev & " " & repos
set results_object = shell.exec(cmd)
log_string = results_object.stdout.readall

' run the svnlook changed command
cmd = svnlook_path & " changed -r " & rev & " " & repos
set results_object = shell.exec(cmd)
changed_string = results_object.stdout.readall

' for debugging
' wscript.echo log_string
' wscript.echo changed_string

' look for the bugid as the first digits in the checkin comment
dim re
set re = new regexp
re.pattern = "^[0-9]*"

dim matches
set matches = re.execute(log_string)

dim bugid
if matches.count > 0 then
set bugid = matches(0)
else
' no digits, nothing to do
wscript.quit 0
end if

' at this point, we have a bugid

dim conn
set conn = createobject("adodb.connection")
conn.open(connection_string)

' loop through the files, the output of the "changed" command
dim lines
lines = split(changed_string, vbcrlf)
if ubound(lines) > 0 then
dim i
for i = 0 to ubound(lines) - 1
dim cols
cols = split(lines(i), " ")
if ubound(cols) = 1 then
dim action
dim file
action = cols(0)
file = cols(1)

dim sql
sql = "insert into bug_file_revisions "
sql = sql & " (bfr_bug, bfr_revision, bfr_action, bfr_file, bfr_date) "
sql = sql & " values ($bug, $rev, N'$act', N'$file', getdate())"
sql = replace(sql,"$bug",bugid)
sql = replace(sql,"$rev",rev)
sql = replace(sql,"$act",action)
sql = replace(sql,"$file",file)

conn.execute(sql)

end if
next
end if

Advertisement


Comments for this entry:

# re: BugTracker.Net and Subversion

I've just posted version 2.6.0 of BugTracker.NET. The Subversion integration is revised and much deeper. For example, you can do diffs from within BugTracker.NET. There are screenshots on my blog on issue trackers.

by Corey Trager on  11/4/2007 10:28 AM
# re: BugTracker.Net and Subversion

Thank you very much. Could you please tell me what will be the svn_path for visual svn server.

by ajeeshco on  4/19/2010 7:42 AM
# re: BugTracker.Net and Subversion

Thx for article!

by Online Bug Tracker on  8/18/2010 7:06 PM

Enter your comment here

Comments are moderated

*


*


 (not displayed)


 (will be a link on your name)

*
Bold Italic Underline Blockquote Hyperlink Hyperlink

 

Please add 5 and 4 and type the answer here:

Comment Preview:

 

Search



About me

Hi, my name is Gurkan Yeniceri. I am a software engineer with 8 years of experience in both public and private sectors. I have been generally writing about software engineering and Microsoft technologies since March 2005 on this site.
View Gurkan Yeniceri's profile on LinkedIn

Contact

If you would like to contact with me you can use the contact page here. I will try to respond it in a timely manner (I will try my best). You can also contact with me via Microsoft Live Messenger with the address gyeniceri {AT} hotmail {DOT} com.
If you are one of my Turkish readers, you may want to visit my Turkish blog here.

If you would like to read my site with an RSS reader like RSS Bandit, you may want to use to subscribe.

RSS 2.0

Advertisement


Bookmark this site

del.icio.us digg NewsVine YahooMyWeb Reddit Spurl TailRank BlinkList Furl Shadows blogmarks
    www.flickr.com
    This is a Flickr badge showing public photos from gurkanyeniceri. Make your own badge here.
    There are 133 posts and 88 comments on this site. Other sites also linked it 7 times.

    Advertisement