I'm looking to create a custom action that will generate an archive file containing only the modified files within a specific commit. Here is the working git call:
git archive -o update.zip HEAD $(git diff-tree --no-commit-id --name-only -r COMMITID)
This works fine on the mac side and also when called directly from the command line but fails when called via a batch file. I suspect there is some kind of syntax issue specifically related to writing this call within a batch file but I'm unable to figure it out. The error generated is:
unknown option `no-commit-id`
I noticed that if I remove the no-commit-id and name-only options the error becomes:
fatal: path not found: $(git
Any help would be greatly appreciated!
That's right. I was able to get an answer from StackOverflow:
setlocal enabledelayedexpansion set output= for /f "delims=" %%a in ('git diff-tree --no-commit-id --name-only -r %1^^') do ( set output=!output! "%%a" ) git archive -o update.zip HEAD %output% endlocal
Here's a solution using 7zip with a Custom Action (Settings > Custom Actions > Add):
Menu caption: > dist.zip
[ ] Open in a separate window
[ ] Show Full Output
[X] Run command silently
Script to run: X:\Your\path\to\7-Zip\7z.exe
Parameters: a $REPO\dist.zip $FILE
(Restart SourceTree after creation for the changes to take effect!)
This action works from the context menu for Unstaged Files and changed files in commits from the Log / History (even with multiple files / multiple commits selected) and will add those files to a "dist.zip" in the repo root. Just note that the file will not be deleted before adding files, so if you want to start from scratch, remember to delete the zip file first.
This has made it so much easier to update live systems with just the files that have changed, in projects where there's no build system involved. I wonder how I was able to live so long without it. :-)
Supported Platforms macOS Windows We recently introduced support for additional hosting services such as GitHub Enterprise, GitLab (Cloud, Community Edition, Enterprise Edition), and...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs