I want to add my ticket name-number automatically to my commits. The ticket value is included as prefix in my branch eg: TESTO-12345-my-branch-name.
This is what I have so far:
<code>customCommands:
- key: "<c-c>"
context: "files"
prompts:
- type: "input"
title: "Add Commit Message"
key: "Message"
command: git commit -m ''$(git branch --contains | grep '*' | awk '{print $2}' | awk -F'-' '{print $1"-"$2}' | awk '{print $1 ":{{.Form.Message}}"}')''
subprocess: true
description: "Custom commit message"
</code>
<code>customCommands:
- key: "<c-c>"
context: "files"
prompts:
- type: "input"
title: "Add Commit Message"
key: "Message"
command: git commit -m ''$(git branch --contains | grep '*' | awk '{print $2}' | awk -F'-' '{print $1"-"$2}' | awk '{print $1 ":{{.Form.Message}}"}')''
subprocess: true
description: "Custom commit message"
</code>
customCommands:
- key: "<c-c>"
context: "files"
prompts:
- type: "input"
title: "Add Commit Message"
key: "Message"
command: git commit -m ''$(git branch --contains | grep '*' | awk '{print $2}' | awk -F'-' '{print $1"-"$2}' | awk '{print $1 ":{{.Form.Message}}"}')''
subprocess: true
description: "Custom commit message"
I am able to make it work when the message has no spaces in it(eg. my-commit-message
). But, if I try to add my commit message
message, it gives me the next error:
<code>error: pathspec 'commit' did not match any file(s) known to git
error: pathspec 'message' did not match any file(s) known to git
</code>
<code>error: pathspec 'commit' did not match any file(s) known to git
error: pathspec 'message' did not match any file(s) known to git
</code>
error: pathspec 'commit' did not match any file(s) known to git
error: pathspec 'message' did not match any file(s) known to git
I think the problem is the last pipe’s awk awk '{print $1 ":{{.Form.Message}}"}'
. Could you please help me to fix it? I do not know how to progress. Thank you.