Reputation: 1498
I'm trying to save the output of a git command to an environment variable in a GitHub Actions step and it's grabbing the first line of the output and leaving off the rest. The container this is running on is ubuntu-latest
.
Here's how I'm trying to capture it:
TMP_CHANGES=`git log origin/master..`
What I expect from echo $TMP_CHANGES
:
commit f179fb811618cc5a2f07637a2ecb394a43ebee21
Author: DannyHinshaw <[email protected]>
Date: Tue Jan 14 07:38:29 2020 -0500
Testing commits diff
commit ed596d2ff2e5bd9801eae6ece7abf627db89f82b
Author: DannyHinshaw <[email protected]>
Date: Tue Jan 14 07:38:28 2020 -0500
Bump version -> v1.2.1-101
commit 40f88031293aba0221b65ed1d2a8295b651ef91b
Author: DannyHinshaw <[email protected]>
Date: Tue Jan 14 07:35:04 2020 -0500
Testing commits diff
What I get:
commit f179fb811618cc5a2f07637a2ecb394a43ebee21
What am I missing? How can I capture and save the full multiline output to the variable while preserving multiline formatting?
Upvotes: 4
Views: 1435
Reputation: 7317
Testing on Ubuntu 18.04.3 LTS
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.3 LTS
Release: 18.04
Codename: bionic
$ git --version
git version 2.17.1
Get log
GT=$(git log -n3 origin/master..)
Echo without ""
$ echo $GT
commit c7c1d60c01b23ba225d79d350d74d0f8990ea8df Author: Ivan <[email protected]> Date: Tue Jan 14 16:05:16 2020 +0300 ref test2 commit 7a52ab307dd6eb2c88cdee83d40dbf2f2ed8c218 Author: Ivan <[email protected]> Date: Tue Jan 14 15:47:16 2020 +0300 ref test2 commit 8f0a2c081a4e731b676c95991d9b182fadd71a95 Author: Ivan <[email protected]> Date: Tue Jan 14 12:45:13 2020 +0300 add more test files
Echo with ""
$ echo "$GT"
commit c7c1d60c01b23ba225d79d350d74d0f8990ea8df
Author: Ivan <[email protected]>
Date: Tue Jan 14 16:05:16 2020 +0300
ref test2
commit 7a52ab307dd6eb2c88cdee83d40dbf2f2ed8c218
Author: Ivan <[email protected]>
Date: Tue Jan 14 15:47:16 2020 +0300
ref test2
commit 8f0a2c081a4e731b676c95991d9b182fadd71a95
Author: Ivan <[email protected]>
Date: Tue Jan 14 12:45:13 2020 +0300
add more test files
Upvotes: 3