2 USING: accessors calendar git-tool git-tool io.directories
3 io.monitors io.pathnames kernel locals math namespaces
4 sequences splitting system threads ui ui.gadgets
5 ui.gadgets.buttons ui.gadgets.labels ui.gadgets.packs ;
9 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
13 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
15 TUPLE: <git-remote-gadget> < pack
25 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
27 : current-branch ( REPO -- branch )
28 { "git" "branch" } git-process stdout>> [ "* " head? ] find nip 2 tail ;
30 : list-branches ( REPO -- branches )
31 { "git" "branch" } git-process stdout>>
35 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
37 : list-remotes ( REPO -- remotes )
38 { "git" "remote" } git-process stdout>> [ empty? not ] filter ;
40 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
42 :: list-remote-branches ( REPO REMOTE -- branches )
43 [let | OUT [ REPO { "git" "remote" "show" REMOTE } git-process stdout>> ] |
45 " Tracked remote branches" OUT member?
48 " Tracked remote branches" OUT index 1 + tail first " " split
53 OUT [ " New remote branches" head? ] find drop
54 1 + tail first " " split
59 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
61 :: refresh-git-remote-gadget ( GADGET -- )
63 [let | REPO [ GADGET repository>> ] |
71 "Repository: " REPO [ current-directory get ] with-directory append
79 "Branch: " <label> add-gadget
93 REPO { "git" "checkout" BRANCH } git-process popup-if-error
94 GADGET refresh-git-remote-gadget
96 <bevel-button> add-gadget
101 "Select a branch" open-window
104 <bevel-button> add-gadget
112 "Remote: " <label> add-gadget
127 GADGET REMOTE >>remote drop
128 GADGET "master" >>remote-branch drop
129 GADGET refresh-git-remote-gadget
131 <bevel-button> add-gadget
136 "Select a remote" open-window
139 <bevel-button> add-gadget
143 ! Remote branch button
147 "Remote branch: " <label> add-gadget
149 GADGET remote-branch>>
155 REPO GADGET remote>> list-remote-branches
162 GADGET REMOTE-BRANCH >>remote-branch drop
163 GADGET refresh-git-remote-gadget
165 <bevel-button> add-gadget
170 "Select a remote branch" open-window
173 <bevel-button> add-gadget
182 [let | REMOTE [ GADGET remote>> ] |
183 REPO { "git" "fetch" REMOTE } git-process popup-if-error ]
185 GADGET refresh-git-remote-gadget
187 <bevel-button> add-gadget
191 [let | REMOTE [ GADGET remote>> ]
192 REMOTE-BRANCH [ GADGET remote-branch>> ] |
194 [let | ARG [ { ".." REMOTE "/" REMOTE-BRANCH } concat ] |
196 [let | PROCESS [ REPO { "git" "log" ARG } git-process ] |
202 "Changes available:" <label> add-gadget
207 PROCESS popup-process-window
209 <bevel-button> add-gadget
215 [let | ARG [ { REMOTE "/" REMOTE-BRANCH } concat ] |
217 REPO { "git" "merge" ARG } git-process popup-process-window
221 GADGET refresh-git-remote-gadget
224 <bevel-button> add-gadget
236 [let | REMOTE [ GADGET remote>> ]
237 REMOTE-BRANCH [ GADGET remote-branch>> ] |
239 [let | ARG [ { REMOTE "/" REMOTE-BRANCH ".." } concat ] |
241 [let | PROCESS [ REPO { "git" "log" ARG } git-process ] |
247 "Pushable changes: " <label> add-gadget
252 PROCESS popup-process-window
254 <bevel-button> add-gadget
260 REPO { "git" "push" REMOTE REMOTE-BRANCH }
264 GADGET refresh-git-remote-gadget
267 <bevel-button> add-gadget
280 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
282 :: start-fetch-thread ( GADGET -- )
284 GADGET f >>closed drop
293 [let | REPO [ GADGET repository>> ]
294 REMOTE-BRANCH [ GADGET remote-branch>> ] |
296 REPO { "git" "fetch" REMOTE-BRANCH } git-process drop ]
298 GADGET fetch-period>> sleep
312 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
314 :: start-monitor-thread ( GADGET -- )
316 GADGET f >>closed drop
320 [let | MONITOR [ GADGET repository>> t <monitor> ] |
327 [let | PATH [ MONITOR next-change drop ] |
333 GADGET last-refresh>> 0 or -
336 GADGET micros >>last-refresh drop
337 GADGET refresh-git-remote-gadget
355 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
357 M: <git-remote-gadget> pref-dim* ( gadget -- dim ) drop { 500 500 } ;
359 M:: <git-remote-gadget> graft* ( GADGET -- )
360 GADGET start-fetch-thread
361 GADGET start-monitor-thread ;
363 M:: <git-remote-gadget> ungraft* ( GADGET -- ) GADGET t >>closed drop ;
365 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
367 :: git-remote-tool ( REPO -- )
369 <git-remote-gadget> new-gadget
371 { 0 1 } >>orientation
378 "master" >>remote-branch
380 5 minutes >>fetch-period
382 dup refresh-git-remote-gadget
384 "git-remote-tool" open-window ;
386 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
388 : factor-git-remote-tool ( -- ) "resource:" git-remote-tool ;
390 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
392 MAIN: factor-git-remote-tool