-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathginger.bat
142 lines (117 loc) · 2.37 KB
/
ginger.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
@echo off
setlocal
:: GINGER - an easy to use git wrapper
:: (c) Severak 2016-19
if "%1" EQU "?" goto help
if "%1" EQU "-h" goto help
if "%1" EQU "/h" goto help
if "%1" EQU "help" goto help
:: ensure we are in repo
git rev-parse --show-toplevel >nul || exit /b
if "%1" EQU "login" goto login
:: ensure we have user
git config user.name >nul || (echo ginger: User not configured. Use: ginger login && exit /b)
:: set codepage
set LC_ALL=C.UTF-8
if "%1" EQU "look" goto look
if "%1" EQU "changed" goto changed
if "%1" EQU "sweep" goto sweep
if "%1" EQU "sweep" goto sweep
if "%1" EQU "branches" goto branches
if "%1" EQU "switch" goto switch
if "%1" EQU "spinoff" goto spinoff
if "%1" EQU "stage" goto stage
if "%1" EQU "unstage" goto unstage
if "%1" EQU "log" goto log
if "%1" EQU "" goto help
echo Error: Unknown command %1
goto :eof
:login
set "_global="
git config user.name >nul || (choice /m "Wanna set global config?" & if %ERRORLEVEL% NEQ 1 set _global=--global)
set /P _username=User name:
set /P _email=E-mail:
git config %_global% user.name "%_username%"
git config %_global% user.email "%_email%"
goto :eof
:look
echo repo:
git rev-parse --show-toplevel
echo branch:
git symbolic-ref --short -q HEAD
echo:
echo user:
git config user.name
git config user.email
echo:
git log --format="format:%%an %%ar:%%n%%h %%s" -n 1
echo:
:: fallthrough to changed
:changed
if "%2" NEQ "" (
git diff -- %2
goto :eof
)
echo -- STAGED:
git diff --name-status --staged
echo -- UNSTAGED:
git diff --name-status
goto :eof
:sweep
if "%2" NEQ "" (
git checkout HEAD -- %2
echo OK
goto :eof
)
git reset --hard HEAD
goto :eof
:branches
git branch -a -v
goto :eof
:switch
if "%2" EQU "" (
echo Error: Please, specify brach name.
exit /b
)
git checkout %2
goto :eof
:spinoff
if "%2" EQU "" (
echo Error: Please, specify brach name.
exit /b
)
git checkout -b %2
goto :eof
:stage
if "%2" EQU "" (
echo Error: Please, provide file name to stage.
exit /b
)
if "%2" EQU "." (
echo staging all changed files...
git add --update
goto :eof
)
git add %2
goto :eof
:unstage
if "%2" EQU "" (
echo Error: Please, provide file name to stage.
exit /b
)
if "%2" EQU "." (
echo staging all changed files...
git reset
goto :eof
)
git reset -- %2
goto :eof
:log
git log
goto :eof
:help
echo GINGER - an easy to use git wrapper
echo (c) Severak 2016-19
echo:
echo No help available yet. See source code.
goto :eof