Git show --color not preserving color when posting to Microsoft Teams

I'm using gitpython and pymsteams to post a git commit message to Microsoft Teams. The local log output shows the diffs in color as expected. However, Teams will not show the color, no matter the --color parameters I specify.

Does anyone know how to preserve the colors here to post to Teams in full?

Code:

import pymsteams
from git import Repo

myTeamsMessage = pymsteams.connectorcard("Teams Webhook URL")

repo = Repo(os.environ[ "OX_REPO_NAME" ])
diff = repo.git.show("--color",os.environ[ "OX_REPO_COMMITREF" ])

msg = '''\
Changes to `%s`:

```diff
%s```
''' % ( os.environ[ "OX_NODE_NAME" ],
diff, 
)

myTeamsMessage.text(msg)
myTeamsMessage.send()

UPDATE ADAPTIVE CARD

I've tried using the adaptive card example from Microsoft but get the exact same output in Teams. [No color, instead weird formatting 33m shows up][1]

url="Teams Webhook URL"

payload2 = {
    "type":"message",
    "attachments":[
       {
          "contentType":"application/vnd.microsoft.card.adaptive",
          "content":{
             "$schema":"http://adaptivecards.io/schemas/adaptive-card.json",
             "type":"AdaptiveCard",
             "version":"1.2",
             "body":[
                 {
                 "type": "TextBlock",
                 "text": msg
                 },
                 
             ]
          }
       }
    ]
 }

headers = {
    'Content-Type': 'application/json'
}
response = requests.post(url, headers=headers, data=json.dumps(payload2))


  [1]: https://i.stack.imgur.com/mv0t4.png

Solution 1:

You can use RichTextBlock to get different colors. It is not possible to post a git commit message with the colors. You have to mention the colors explicitly.