summaryrefslogtreecommitdiffstats
path: root/qa/utils.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-09 13:38:02 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-09 13:38:02 +0000
commit6f442e774b9236c999f36c2d7af17640f49bff99 (patch)
tree47e73755bffd41bdde2d59d76cc595f5a1fa75d4 /qa/utils.py
parentInitial commit. (diff)
downloadgitlint-6f442e774b9236c999f36c2d7af17640f49bff99.tar.xz
gitlint-6f442e774b9236c999f36c2d7af17640f49bff99.zip
Adding upstream version 0.19.1.upstream/0.19.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'qa/utils.py')
-rw-r--r--qa/utils.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/qa/utils.py b/qa/utils.py
new file mode 100644
index 0000000..d560d86
--- /dev/null
+++ b/qa/utils.py
@@ -0,0 +1,48 @@
+import locale
+import os
+import platform
+
+########################################################################################################################
+# PLATFORM_IS_WINDOWS
+
+
+def platform_is_windows():
+ return "windows" in platform.system().lower()
+
+
+PLATFORM_IS_WINDOWS = platform_is_windows()
+
+########################################################################################################################
+# USE_SH_LIB
+# Determine whether to use the `sh` library
+# On windows we won't want to use the sh library since it's not supported - instead we'll use our own shell module.
+# However, we want to be able to overwrite this behavior for testing using the GITLINT_QA_USE_SH_LIB env var.
+
+
+def use_sh_library():
+ gitlint_use_sh_lib_env = os.environ.get("GITLINT_QA_USE_SH_LIB", None)
+ if gitlint_use_sh_lib_env:
+ return gitlint_use_sh_lib_env == "1"
+ return not PLATFORM_IS_WINDOWS
+
+
+USE_SH_LIB = use_sh_library()
+
+########################################################################################################################
+# TERMINAL_ENCODING
+# Encoding for reading gitlint command output
+
+
+def getpreferredencoding():
+ """Use local.getpreferredencoding() or fallback to UTF-8."""
+ return locale.getpreferredencoding() or "UTF-8"
+
+
+TERMINAL_ENCODING = getpreferredencoding()
+
+
+########################################################################################################################
+# FILE_ENCODING
+
+# Encoding for reading/writing files within the tests, this is always UTF-8
+FILE_ENCODING = "UTF-8"