1

My ASP.NET MVC web app is written using C# and uses SQL Server stored procedures.

I am using Git for code source control, and each time I deploy, I will create a tag to define the version deployed.

Example: tag1_2021_07_29_11_00, tag2_2021_07_30_09_01... and the tag will be time I deploy, this time deploy can random.

And the stored procedure I need to run is list file between two tag:
tag2_2021_07_30_09_01 and tag1_2021_07_29_11_00.

(Example sp1.sql, sp2.sql, sp3.sql I will run it in SQL Server Management Studio)

I want to automate the deployment with cmd for saving time.

I created successfully cmd command to build and export deployment web source code, but i don't know the command to export my .sql file between tag1 and tag2 into one folder.

Do note that I see that TortoiseGit has a function "export this version.." when I show git log and choose my list SQL stored procedure file sp1.sql,sp2.sql...

Could anyone help me to achieve my goal using cmd to export list store?


This is my cmd build command, I need and some cmd line to export list SQL to compress with my source (into deploy_PROD_%datetime%.7z):

@echo off
for /f %%a in ('powershell -Command "Get-Date -format yyyy.MM.dd__HH.mm"') do set datetime=%%a

del /s /q  "D:\botdeploy\*"
cd /D D:\Source & git checkout PROD & git pull & git tag PROD_deploy_%datetime% & git push --tags
cd /D "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Msbuild" D:\Source\CRM.csproj  /t:Restore,Rebuild /p:outdir="D:\botdeploy\\" /p:Configuration=Release & del  /q "D:\botdeploy\_PublishedWebsites\CRM\Web.config" & "C:\Program Files\7-Zip\7z" a -t7z C:\Users\Nam\Desktop\deploy_PROD_%datetime%.7z D:\botdeploy\_PublishedWebsites\CRM\*
pause
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

0

If you are looking to list files added/modified (but not removed) between two tags, see, as in here

git diff --name-only --relative --diff-filter=AM tag1 tag2 > list

Once you have a list of files, you could use it in a dedicated cloned repository where you can sparse checkout only the files you want (with git sparse-checkout):

git clone --filter=blob:none --no-checkout --branch tag2 /url/remote/repo
cd repo
git sparse-checkout init 
# for each file in list
git sparse-checkout add <aFile>
git read-tree -mu HEAD

Finally, you can git archive that repository, in order to get an archive with only the files you want, at the right version (tag2, the most recent one)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250