|
1 | 1 | {r}←CheckForGit(path config parms);status;dmx;gitStatus;ind |
2 | 2 | ⍝ Checks whether the project is managed by Git, and if so offers some help, unless parms.batch=1 |
3 | 3 | r←⍬ |
| 4 | + →(~F.Exists(AddSlash path),'.git')/0 |
4 | 5 | gitStatus←GetGlobalGitStatus |
5 | 6 | :If gitStatus≠0 |
6 | | - :AndIf F.Exists(AddSlash path),'.git' |
7 | | - :If gitStatus=3 |
8 | | - ind←'Report Git status?'C.Select'Nope!' 'Yes, in ⎕ED' 'Yes, in the session' |
| 7 | + :If gitStatus=3 ⍝ We need to ask the user |
| 8 | + ind←'Report Git status (if anything is to report) ?'C.Select'Nope!' 'Yes, in ⎕ED' 'Yes, in the session' |
9 | 9 | →(1=ind)/0 |
| 10 | + gitStatus←(2 3⍳ind)⊃1 2 |
10 | 11 | :EndIf |
11 | | - :Trap 0 |
12 | | - status←G.Status path |
| 12 | + :EndIf |
| 13 | + :Trap 0 |
| 14 | + status←G.Status path |
| 15 | + :Else |
| 16 | + dmx←⎕DMX |
| 17 | + :If 127=dmx.EN |
| 18 | + (1 parms.batch)p'The project appears to be managed by Git but Git is not installed?!' |
| 19 | + :ElseIf 128=dmx.EN |
| 20 | + (1 parms.batch)p'The project appears to be managed by Git but user.email and/or user.name are not defined' |
| 21 | + :ElseIf 0<≢dmx.Message |
| 22 | + (1 parms.batch)p'The Git status of the project could not be determined due to an error:' |
| 23 | + (1 parms.batch)p dmx.Message,'; rc=',⍕dmx.EN |
| 24 | + :ElseIf 0<≢dmx.DM |
| 25 | + (1 parms.batch)p'The Git status of the project could not be determined due to an error:' |
| 26 | + (1 parms.batch)p(⊃dmx.DM),'; rc=',⍕dmx.EN |
| 27 | + :Else |
| 28 | + (1 parms.batch)p'The Git status of the project could not be determined due to an error' |
| 29 | + :Return |
| 30 | + :EndIf |
| 31 | + :Return |
| 32 | + :EndTrap |
| 33 | + :If ∧/∨/¨'nothing to commit' 'working tree clean'⍷¨⊂∊status |
| 34 | + :AndIf ~∨/∨/¨'on branch main' 'on branch master'⍷¨⊂⎕C∊status |
| 35 | + status←(↓(,[0.5]'Git status report')⍪'='),status |
| 36 | + p status |
| 37 | + :ElseIf 0=parms.batch |
| 38 | + status←(↓(,[0.5]'Git status report')⍪'='),status |
| 39 | + :If gitStatus=1 |
| 40 | + {{}(#.⎕NS'').(⎕ED⍠('ReadOnly' 1)&{'GIT_Status_Report'}GIT_Status_Report←⍵)}⍪status |
13 | 41 | :Else |
14 | | - dmx←⎕DMX |
15 | | - :If 127=dmx.EN |
16 | | - (1 parms.batch)p'The project appears to be managed by Git but Git is not installed?!' |
17 | | - :Return |
18 | | - :ElseIf 128=dmx.EN |
19 | | - (1 parms.batch)p'The project appears to be managed by Git but user.email and/or user.name are not defined' |
20 | | - :Return |
21 | | - :ElseIf 0<≢dmx.Message |
22 | | - (1 parms.batch)p'The Git status of the project could not be determined due to an error:' |
23 | | - (1 parms.batch)p dmx.Message,'; rc=',⍕dmx.EN |
24 | | - :Return |
25 | | - :Else |
26 | | - (1 parms.batch)p'The Git status of the project could not be determined due to an error' |
27 | | - :Return |
28 | | - :EndIf |
29 | | - :EndTrap |
30 | | - :If ∧/∨/¨'nothing to commit' 'working tree clean'⍷¨⊂∊status |
31 | | - :AndIf ~∨/∨/¨'on branch main' 'on branch master'⍷¨⊂⎕C∊status |
32 | | - (1 parms.batch)p'Git: ',(1⊃status),', ',⊃{⍺,', ',⍵}/1↓status |
33 | | - :ElseIf 0=parms.batch |
34 | | - status←(↓(,[0.5]'Git status report')⍪'='),status |
35 | | - :If gitStatus=1 |
36 | | - {{}(#.⎕NS'').(⎕ED⍠('ReadOnly' 1)&{'GIT_Status_Report'}GIT_Status_Report←⍵)}⍪status |
37 | | - :Else |
38 | | - ⎕←↑status |
39 | | - :EndIf |
| 42 | + ⎕←↑status |
40 | 43 | :EndIf |
41 | 44 | :EndIf |
0 commit comments