Add a function to access the Git config
[lilypond/dscho.git] / lilycontrib.tcl
blob95f459a5cf37d1a7a3e16ced8020f01cbaf54db9
1 #!/usr/bin/wish
3 package require Tk
5 wm title . "LilyPond Contributor's GUI"
6 button .update -text "Update LilyPond" -command update_lilypond
7 panedwindow .output
8 text .output.text -width 80 -height 15 \
9 -xscrollcommand [list .output.horizontal set] \
10 -yscrollcommand [list .output.vertical set]
11 scrollbar .output.horizontal -orient h -command [list .output.text xview]
12 scrollbar .output.vertical -orient v -command [list .output.text yview]
13 pack .output.horizontal -side bottom -fill x
14 pack .output.vertical -side right -fill y
15 pack .output.text -expand true -anchor nw -fill both
16 pack .update .output
18 set lily_dir $env(HOME)/lilypond
19 cd $lily_dir
20 if {![file exists $lily_dir]} {
21 .update configure -text "Clone LilyPond"
24 proc write_to_output {s} {
25 .output.text insert insert $s
26 .output.text see end
29 proc write_file_to_output {f} {
30 if {[eof $f]} {
31 global git_command
32 fconfigure $f -blocking true
33 if {[catch {close $f} err]} {
34 tk_messageBox -type ok -message "Git aborted: $err"
36 unset git_command
37 } else {
38 write_to_output [read $f 24]
42 proc git {args} {
43 global lily_dir git_command
44 file mkdir $lily_dir
45 set git_command [linsert $args 0 "|git" "--git-dir=$lily_dir/.git"]
46 set git_command "$git_command 2>@1"
47 #.output.text insert end "$git_command\n"
48 set git [open $git_command r]
49 fconfigure $git -blocking false
50 fileevent $git readable [list write_file_to_output $git]
51 vwait git_command
54 proc config {args} {
55 global lily_dir
56 set p [open [linsert $args 0 "|git" --git-dir=$lily_dir/.git config] r]
57 set result [regsub "\n\$" [read $p] ""]
58 close $p
59 return $result
62 proc update_lilypond {} {
63 global lily_dir
64 if {![file exists $lily_dir]} {
65 file mkdir $lily_dir
66 git init
67 git config core.bare false
68 git remote add -t master \
69 origin git://repo.or.cz/lilypond.git
70 git fetch --depth 1
71 git reset --hard origin/master
72 git config branch.master.remote origin
73 git config branch.master.merge refs/heads/master
74 .update configure -text "Update LilyPond"
75 } else {
76 git fetch origin
77 git merge origin/master
79 write_to_output "Done.\n"