fix(git-server): do not output emoji to asci-only git sideband
+ 24
- 11
app/services/gitServer/onPushEvent.ts
@@ -7,6 +7,11 @@ import { Env } from "../../env";
 import { GitServerServiceDeps } from "./types";
 import { getEnv } from "../../utils/server";
 
+const toAscii = (str: string) => {
+  // replace emoji with nothing
+  return str.replace(/[\u{1F600}-\u{1F64F}]/gu, "");
+};
+
 const makeOnPushEvent: ServiceMethodFactory<
   GitServerServiceDeps,
   [GitServer.Event],

...
@@ -51,27 +56,35 @@ const makeOnPushEvent: ServiceMethodFactory<
           : `${repoUrlPrefix}:${Env.PORT}/${repoUrlSuffix}`;
 
       if (data.payload != null) {
-        message.write(`Hey ${data.username}, welcome back 🖖.\n\n`);
-        message.write(`📖 See the details of your push at:\n`);
+        message.write(toAscii(`Hey ${data.username}, welcome back 🖖.\n\n`));
+        message.write(toAscii(`📖 See the details of your push at:\n`));
         if (data.payload.refType === "head") {
-          message.write(`🔗 ${repoUrlBase}/show/${data.payload.commitId}\n`);
+          message.write(
+            toAscii(`🔗 ${repoUrlBase}/show/${data.payload.commitId}\n`),
+          );
           if (data.payload.refName !== Const.PRIMARY_BRANCH_REF) {
             message.write(`\n`);
             // todo: if pr already exist, link to it instead of new pr page
             message.write(
-              `🚀 Quickly create a pull-request from this branch at:\n`,
+              toAscii(
+                `🚀 Quickly create a pull-request from this branch at:\n`,
+              ),
             );
             message.write(
-              `🔗 ${repoUrlBase}/pulls/new?from_branch=${encodeURIComponent(
-                data.payload.refName,
-              )}\n`,
+              toAscii(
+                `🔗 ${repoUrlBase}/pulls/new?from_branch=${encodeURIComponent(
+                  data.payload.refName,
+                )}\n`,
+              ),
             );
           }
         } else if (data.payload.refType === "tag") {
           message.write(
-            `🏷 ${repoUrlBase}/tags/${encodeURIComponent(
-              data.payload.refName,
-            )}\n`,
+            toAscii(
+              `🏷 ${repoUrlBase}/tags/${encodeURIComponent(
+                data.payload.refName,
+              )}\n`,
+            ),
           );
         }
       }

...
@@ -82,7 +95,7 @@ const makeOnPushEvent: ServiceMethodFactory<
       // it is receiving, server is uploading
       console.log("upload-pack");
       // ⬇️ disabled because it seem to cause issues on git pull. ⬇️
-      // message.write(`🖖 Welcome at GitFOSS ${data.username}!\n`);
+      message.write(toAscii(`🖖 Welcome at GitFOSS ${data.username}!\n`));
     }
 
     // Finally, accept the payload from client