forked from wplacer/wplacer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate.bat
More file actions
134 lines (119 loc) · 3.16 KB
/
update.bat
File metadata and controls
134 lines (119 loc) · 3.16 KB
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
@echo off
setlocal enabledelayedexpansion
echo Verifying Git Installation...
git --version >nul 2>&1
if %errorlevel% equ 0 (
echo Git found!
echo.
goto :git_pull
)
echo Git not found!
echo.
echo Checking if winget is available...
winget --version >nul 2>&1
if %errorlevel% neq 0 (
echo Winget not found!
echo.
echo Winget is required to install Git automatically.
echo Please install Git manually at: https://git-scm.com/
echo Or upgrade to Windows 10 version 1809+ or Windows 11.
echo.
pause
exit /b 1
)
echo Winget found!
echo.
echo Installing Git with winget...
echo This can take a few minutes.
echo.
winget install --id Git.Git -e --source winget --accept-package-agreements --accept-source-agreements
if %errorlevel% neq 0 (
echo.
echo Installation failed!
echo Try to install manually at: https://git-scm.com/
echo.
pause
exit /b 1
)
echo.
echo Git successfully installed!
echo.
echo Git has been installed and PATH updated by winget.
echo To use Git, you must restart your command prompt (terminal) for PATH changes to take effect.
echo After restarting, please run this script again.
echo.
pause
exit /b 0
:git_pull
echo Repository:
git remote get-url origin 2>nul
if %errorlevel% neq 0 (
echo Could not determine the remote repository.
echo Make sure you are in a folder with an initialized Git repository.
echo.
goto :end
)
echo.
echo Current branch:
git branch --show-current 2>nul
if %errorlevel% neq 0 (
echo Could not determine current branch.
)
echo.
echo Checking for local changes...
git status --porcelain 2>nul | findstr /r "." >nul
if %errorlevel% equ 0 (
echo.
echo WARNING: You have local changes in your repository!
echo.
git status --short 2>nul
echo.
set /p "discard=Do you want to discard all local changes? (y/N - default is No): "
if /i "!discard!" equ "Y" (
echo.
echo Discarding local changes...
git checkout . 2>&1
if %errorlevel% equ 0 (
echo Local changes discarded successfully!
) else (
echo Error discarding local changes.
echo You may need to resolve this manually.
echo.
goto :end
)
) else (
echo.
echo Keeping local changes. Update cancelled.
echo Please commit, stash, or manually resolve your changes before updating.
echo.
goto :end
)
echo.
)
echo Checking for remote changes...
git fetch origin 2>&1
if %errorlevel% neq 0 (
echo Warning: Could not fetch from remote repository.
echo Note: Without a successful fetch, 'git pull' will likely fail. Please check your internet connection and remote repository configuration.
echo.
)
echo Updating repository...
git pull
if %errorlevel% equ 0 (
echo.
echo Repository updated successfully!
) else (
echo.
echo Error updating the repository.
echo Possible causes:
echo - No internet connection
echo - Authentication required
echo - Merge conflicts
echo - No remote repository configured
echo.
echo You may need to resolve conflicts manually or check your credentials.
)
:end
echo.
echo All done!
pause