Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 88 lines (72 sloc) 3.668 kb
a2ca506 Initial check-in
philipf authored
1 ' Fix FogBugz util.asp for use with gitweb
2 '
3 ' Usage:
4 ' cscript FixFogBugzUtilAsp.vbs <fb install dir>
5 ' If <fb install dir> is not specified it will look for the file in the default FB install directory:
6 ' C:\Program Files\FogBugz\
7 '
8 ' Author : Philip Fourie
9 ' Created: 2009/01/10
10 ' Version: 1.0
11 ' Location: http://softwarerealisations.com/fbgit.html
12 '
13 ' Important:
14 ' When upgrading FogBugz this script these changes will be lost and the script needs to be ran again.
15 '
16 ' Function:
17 ' Replaces two occurrences of URL encoding that is required for calls gitweb to work.
18 ' FogBugz unfortunately URL encode ^R1 and ^R2 and gitweb can't parse the query parameters.
19 '
20 ' The text to be replaced are found in FogBugz\website\util.asp for following methods:
21 ' GetSourceControlViewFileURL
22 ' GetSourceControlViewFileURL = Replace(ReplaceInUrl(ReplaceInUrl(ReplaceInUrl(g_config.sCVSView, "^FILE", sFile), "^R1", r1), "^R2", r2), "^REPO", sRepo)
23 ' should be changed to:
24 ' GetSourceControlViewFileURL = Replace(Replace(Replace(ReplaceInUrl(g_config.sCVSView, "^FILE", sFile), "^R1", r1), "^R2", r2), "^REPO", sRepo)
25 '
26 '
27 ' - GetSourceControlDiffFileURL
28 ' GetSourceControlDiffFileURL = Replace(ReplaceInUrl(ReplaceInUrl(ReplaceInUrl(g_config.sCVSDiff, "^FILE", sFile), "^R1", r1), "^R2", r2), "^REPO", sRepo)
29 ' should be changed to:
30 ' GetSourceControlDiffFileURL = Replace(Replace(Replace(ReplaceInUrl(g_config.sCVSDiff, "^FILE", sFile), "^R1", r1), "^R2", r2), "^REPO", sRepo)
31 '
32 ' Tested against:
33 ' FogBugz version 6.1.41 and git 1.6.1
34 '
35 '
36
37 ' Use default install location if script wasn't called with a FB location argument
38 If WScript.Arguments.Count = 0 Then
39 installDir = "c:\Program Files\FogBugz"
40 Else
41 installDir = WScript.Arguments(0)
42 End If
43
44 ' This the absolute location of the file that needs to change
45 utilFile = installDir & "\website\util.asp"
46
47 Set objFSO = CreateObject("Scripting.FileSystemObject")
48
49 If (objFSO.FileExists(utilFile) = False) Then
50 WScript.Echo ("Failed. Could not find file: " & utilFile)
51 WScript.Quit(1)
52 End If
53
54 WScript.Echo "Replacing contents of: " + utilFile
55
56 ' New code to swap in
57 oldViewFileLine = "GetSourceControlViewFileURL = Replace(ReplaceInUrl(ReplaceInUrl(ReplaceInUrl(g_config.sCVSView, ""^FILE"", sFile), ""^R1"", r1), ""^R2"", r2), ""^REPO"", sRepo)"
58 newViewFileLine = "GetSourceControlViewFileURL = Replace(Replace(Replace(ReplaceInUrl(g_config.sCVSView, ""^FILE"", sFile), ""^R1"", r1), ""^R2"", r2), ""^REPO"", sRepo)"
59
60 oldDiffFileLine = "GetSourceControlDiffFileURL = Replace(ReplaceInUrl(ReplaceInUrl(ReplaceInUrl(g_config.sCVSDiff, ""^FILE"", sFile), ""^R1"", r1), ""^R2"", r2), ""^REPO"", sRepo)"
61 newDiffFileLine = "GetSourceControlDiffFileURL = Replace(Replace(Replace(ReplaceInUrl(g_config.sCVSDiff, ""^FILE"", sFile), ""^R1"", r1), ""^R2"", r2), ""^REPO"", sRepo)"
62
63 Const ForReading = 1
64 Const ForWriting = 2
65
66 Set objFile = objFSO.OpenTextFile(utilFile, ForReading)
67
68 oldText = objFile.ReadAll
69 objFile.Close
70 newText1 = Replace(oldText, oldViewFileLine, newViewFileLine)
71 If (oldText = newText1) Then
72 WScript.Echo ("Did not find anything to replace for ViewFile logic. Maybe the script was already run (not serious) or FogBugz code has changed since writing the fix (serious)")
73 End If
74
75 newText2 = Replace(newText1, oldDiffFileLine, newDiffFileLine)
76 If (newText1 = newText2) Then
77 WScript.Echo ("Did not find anything to replace for DiffFile logic. Maybe the script was already run (not serious) or FogBugz code has changed since writing the fix (serious)")
78 End If
79
80 Set objFile = objFSO.OpenTextFile(utilFile, ForWriting)
81 objFile.WriteLine newText2
82 objFile.Close
83
84
85 WScript.Echo ("Completed")
86
87
88 ' EOF
Something went wrong with that request. Please try again.