Last active
June 1, 2023 10:44
-
-
Save agiannis/37cb0c9e1857fd674661 to your computer and use it in GitHub Desktop.
label: git
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
REM Upload git changes to ftp with the help of WinSCP | |
REM USAGE: go to the project root directory and just hit upload_changes. | |
REM The root directory must have a upload.conf file with winscp_host,remote_path data. | |
REM "winscp_host" is the name of WinSCP host name. | |
REM Check WinSCP directory is set correctly | |
REM Get changes from n latest commits | |
set latest=%1 | |
REM set winscp_host="testsite.com" | |
REM set remote_path="/public_html" | |
set local_path="%cd%\git_changed_files\" | |
REM Set path data (eg winscp_host=_2015/demolab) | |
for /f "delims== tokens=1,2" %%G in (upload.conf) do set %%G=%%H | |
REM create a local directory git_changed_files and put inside all git changes | |
for /f "usebackq tokens=*" %%A in (`git diff-tree -r --no-commit-id --name-only --diff-filter=ACMRT HEAD~%latest% HEAD`) do IF "%%A" NEQ "update.sql" (echo f | xcopy /f /y "%%A" "%local_path%\%%A") > nul | |
REM upload local folder to remote | |
"C:\My Programs\WinSCP\WinSCP.com" %winscp% %winscp_host% /command "option confirm off" "put "%local_path%" "%remote_path%"" "bye" | |
REM Removing local directory | |
RD /s /q %local_path% | |
echo. | |
%extra_comand% | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment