I have a question about ad-hoc Git configuration.
I need to pass tag name on tag post or any commit to e.g.
#!/bin/bash
while read oldrev newrev refname
do
branch=$(git rev-parse --symbolic --abbrev-ref $refname)
curl -X POST "https://en4c6i2k7daz5.x.pipedream.net/" \
-H 'Content-Type: application/json' \
-d '{"version": "$refname"}'
done
In the result I'm getting (see https://requestbin.com/r/en4c6i2k7daz5/1cxY1mJeMlejAnF0OJ8B8iCd6sl)
{"version": "$refname"}
So for some reason it is not sending tag name (value of the $refname) - what is wrong in the script?
You're single-quoting your data, single-quotes exist to shut off the shell's string-construction syntax, expansions and wordsplitting and the rest. Since refnames can't have white space or glob syntax in them I think you can get by without quoting their expansionss, but for safety I usually do, to control the expansions I'll usually switch from single quotes to double quotes as needed to get that:
or you could just do it all double-quotes and escape json's redundant ones to shoehorn them in that way:
edit: hmmm, from
git help check-ref-formatI'm gettingi.e. you' guaranteed to not have to quote refname expansions at all.