Add envvar to enable automatic .gitignore creation for workdirs
authorJannis Harder <me@jix.one>
Mon, 11 Apr 2022 15:35:11 +0000 (17:35 +0200)
committerJannis Harder <me@jix.one>
Mon, 11 Apr 2022 15:44:10 +0000 (17:44 +0200)
sbysrc/sby.py

index 5616bc0f0d76795d5449caeb55226fb956b98481..d28cd29b0ac1802ddfdb4b7463eac65cbb0f0805 100644 (file)
@@ -415,6 +415,10 @@ def run_task(taskname):
         my_opt_tmpdir = True
         my_workdir = tempfile.mkdtemp()
 
+    if os.getenv("SBY_WORKDIR_GITIGNORE"):
+        with open(f"{my_workdir}/.gitignore", "w") as gitignore:
+            print("*", file=gitignore)
+
     junit_ts_name = os.path.basename(sbyfile[:-4]) if sbyfile is not None else workdir if workdir is not None else "stdin"
     junit_tc_name = taskname if taskname is not None else "default"