Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions git-slack-hook
Original file line number Diff line number Diff line change
Expand Up @@ -243,15 +243,26 @@ function notify() {
fi

# Process the log and escape double quotes; assuming for now that committer names don't have five semicolons in them
log_out=$( git log --pretty=format:"%cN;;;;;${formattedurl}${commitformat}" $countarg ${start}..${end} \
| sed ':a;N;$!ba;s/\n/\\n/g' \
| sed -e 's/\\/\\\\/g' \
| sed -e 's/"/\\"/g' \
| sed -e 's/\(.*\);;;;;\(.*\)/{"title":"\1","value":"\2","short":false},/' )
if $onlylast; then
log_out=$( git log --pretty=format:"%cN;;;;;${formattedurl}${commitformat}" $countarg ${start}..${end} \
| sed ':a;N;$!ba;s/\n/\\n/g' \
| sed -e 's/\\/\\\\/g' \
| sed -e 's/"/\\"/g' \
| sed -e 's/\(.*\);;;;;\(.*\)/{"title":"\1","value":"\2","short":false},/' )
fields=${log_out%?}
attachments="[{ \"fallback\" : \"${header}\", \"color\" : \"good\", \"fields\" : [${fields}]}]"

fields=${log_out%?}
else
log_out=$( git log --pretty=format:"%cN;;;;;${formattedurl}${commitformat}" $countarg ${start}..${end} \
| sed ':a;N;$!ba;s/\n+/\\n/g' \
| sed -e 's/\\/\\\\/g' \
| sed -e 's/"/\\"/g' \
| sed -e 's/\(.*\);;;;;\(.*\)/{ \"fallback\" : \"\", \"color\" : \"good\", \"fields\" : [{"title":"\1","value":"\2","short":false},]},/' \
| sed -e 's/,\]/]/' )

attachments="[${log_out%?}]"
fi

attachments="[{ \"fallback\" : \"${header}\", \"color\" : \"good\", \"fields\" : [${fields}]}]"
fi

if [ -n "${attachments}" ] && [[ "${attachments}" != "" ]]; then
Expand Down