gitweb: Add test t9500 for gitweb (as standalone script)
[git/jnareb-git.git] / git-gui / lib / shortcut.tcl
blobebf72e44521feac5619842227f61e4e5f26a819a
1 # git-gui desktop icon creators
2 # Copyright (C) 2006, 2007 Shawn Pearce
4 proc do_windows_shortcut {} {
5 global argv0
7 set fn [tk_getSaveFile \
8 -parent . \
9 -title "[appname] ([reponame]): Create Desktop Icon" \
10 -initialfile "Git [reponame].bat"]
11 if {$fn != {}} {
12 if {[catch {
13 set fd [open $fn w]
14 puts $fd "@ECHO Entering [reponame]"
15 puts $fd "@ECHO Starting git-gui... please wait..."
16 puts $fd "@SET PATH=[file normalize [gitexec]];%PATH%"
17 puts $fd "@SET GIT_DIR=[file normalize [gitdir]]"
18 puts -nonewline $fd "@\"[info nameofexecutable]\""
19 puts $fd " \"[file normalize $argv0]\""
20 close $fd
21 } err]} {
22 error_popup "Cannot write script:\n\n$err"
27 proc do_cygwin_shortcut {} {
28 global argv0
30 if {[catch {
31 set desktop [exec cygpath \
32 --windows \
33 --absolute \
34 --long-name \
35 --desktop]
36 }]} {
37 set desktop .
39 set fn [tk_getSaveFile \
40 -parent . \
41 -title "[appname] ([reponame]): Create Desktop Icon" \
42 -initialdir $desktop \
43 -initialfile "Git [reponame].bat"]
44 if {$fn != {}} {
45 if {[catch {
46 set fd [open $fn w]
47 set sh [exec cygpath \
48 --windows \
49 --absolute \
50 /bin/sh]
51 set me [exec cygpath \
52 --unix \
53 --absolute \
54 $argv0]
55 set gd [exec cygpath \
56 --unix \
57 --absolute \
58 [gitdir]]
59 set gw [exec cygpath \
60 --windows \
61 --absolute \
62 [file dirname [gitdir]]]
63 regsub -all ' $me "'\\''" me
64 regsub -all ' $gd "'\\''" gd
65 puts $fd "@ECHO Entering $gw"
66 puts $fd "@ECHO Starting git-gui... please wait..."
67 puts -nonewline $fd "@\"$sh\" --login -c \""
68 puts -nonewline $fd "GIT_DIR='$gd'"
69 puts -nonewline $fd " '$me'"
70 puts $fd "&\""
71 close $fd
72 } err]} {
73 error_popup "Cannot write script:\n\n$err"
78 proc do_macosx_app {} {
79 global argv0 env
81 set fn [tk_getSaveFile \
82 -parent . \
83 -title "[appname] ([reponame]): Create Desktop Icon" \
84 -initialdir [file join $env(HOME) Desktop] \
85 -initialfile "Git [reponame].app"]
86 if {$fn != {}} {
87 if {[catch {
88 set Contents [file join $fn Contents]
89 set MacOS [file join $Contents MacOS]
90 set exe [file join $MacOS git-gui]
92 file mkdir $MacOS
94 set fd [open [file join $Contents Info.plist] w]
95 puts $fd {<?xml version="1.0" encoding="UTF-8"?>
96 <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
97 <plist version="1.0">
98 <dict>
99 <key>CFBundleDevelopmentRegion</key>
100 <string>English</string>
101 <key>CFBundleExecutable</key>
102 <string>git-gui</string>
103 <key>CFBundleIdentifier</key>
104 <string>org.spearce.git-gui</string>
105 <key>CFBundleInfoDictionaryVersion</key>
106 <string>6.0</string>
107 <key>CFBundlePackageType</key>
108 <string>APPL</string>
109 <key>CFBundleSignature</key>
110 <string>????</string>
111 <key>CFBundleVersion</key>
112 <string>1.0</string>
113 <key>NSPrincipalClass</key>
114 <string>NSApplication</string>
115 </dict>
116 </plist>}
117 close $fd
119 set fd [open $exe w]
120 set gd [file normalize [gitdir]]
121 set ep [file normalize [gitexec]]
122 regsub -all ' $gd "'\\''" gd
123 regsub -all ' $ep "'\\''" ep
124 puts $fd "#!/bin/sh"
125 foreach name [array names env] {
126 if {[string match GIT_* $name]} {
127 regsub -all ' $env($name) "'\\''" v
128 puts $fd "export $name='$v'"
131 puts $fd "export PATH='$ep':\$PATH"
132 puts $fd "export GIT_DIR='$gd'"
133 puts $fd "exec [file normalize $argv0]"
134 close $fd
136 file attributes $exe -permissions u+x,g+x,o+x
137 } err]} {
138 error_popup "Cannot write icon:\n\n$err"