1

So I am attempting to create list of modified files between two git commands:

shell_exec("
  git diff --name-only $remoteCommitId $localCommitId > diff &&
  SET /p DIFF=<diff &&
  git archive --output=$zipName HEAD %DIFF%
");

However, no zip file is created I also tried separating commands with & and ;. If a run these commands in batch file, everything works.

I am on windows and the reason why I am doing it that way is here.

I just want to create zip file between two git commits via shell_exec so any other method which works via shell_exec is also welcome.

Update

If I run these commands directly on console:

git diff --name-only 207b606c270fc14a7161647c2fbe8f9a7d8e05a1 17dcc2233678df4ce86c8713e0349d68e45c3c96 > diff&& SET /p DIFF=<diff&& git archive --output=deployment.zip HEAD %DIFF%

It does create deployment.zip file but problem is that deployment.zip file only contains single root path file in it not ones from other folder (vendor in this case):

Here is diff file:

composer.json
vendor/anlutro/l4-settings/.gitignore
vendor/anlutro/l4-settings/.travis.yml
vendor/anlutro/l4-settings/CONTRIBUTING.md
vendor/anlutro/l4-settings/LICENSE
vendor/anlutro/l4-settings/README.md
vendor/anlutro/l4-settings/composer.json
vendor/anlutro/l4-settings/phpunit.xml
vendor/anlutro/l4-settings/src/ArrayUtil.php
vendor/anlutro/l4-settings/src/DatabaseSettingStore.php
vendor/anlutro/l4-settings/src/Facade.php
vendor/anlutro/l4-settings/src/JsonSettingStore.php
vendor/anlutro/l4-settings/src/MemorySettingStore.php

But deployment.zip file only contains composer.json file.

23
  • CA you try ...> diff&& set... diff&& git ...: ie, no space after the last character of one command, and its separator &&. I just want to be sure you are no create diff instead of diff Commented Aug 13, 2017 at 13:26
  • Are you sure all your commands are succeeding? You tagged this with bash but some of those are windows cmd commands/syntax, not bash Commented Aug 13, 2017 at 13:35
  • @VonC: Please see updated question, i tried that way. Commented Aug 13, 2017 at 13:36
  • @EricRenouf: Yes when i run individually/directly on console, I don't see any errors but even with this method it only generates deployment file with single composer.json file in it, not all files. Please see updated question. Commented Aug 13, 2017 at 13:38
  • Can you try SET /p "DIFF=<diff" in order to preserve the newlines? Commented Aug 13, 2017 at 13:38

1 Answer 1

1

Try instead:

 shell_exec("cmd /C \"ascript.bat\"");

with ascript.bat a script which list all the necessary commands.
See "how not to open a Cmd window when running a batch file"

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.