From 60973bcea52eae2f1d3afab76c508abfbb867242 Mon Sep 17 00:00:00 2001
From: Michael Boniface <m.j.boniface@soton.ac.uk>
Date: Sun, 23 Feb 2025 21:24:49 +0000
Subject: [PATCH] added gitignore to phen init. closes #4

---
 acmc/parse.py |  7 ++++---
 acmc/phen.py  | 20 +++++++++++++-------
 2 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/acmc/parse.py b/acmc/parse.py
index a2996ed..ca5b3e1 100644
--- a/acmc/parse.py
+++ b/acmc/parse.py
@@ -39,14 +39,15 @@ class Proto:
         tuple[
             str,  # The description, e.g., "Not Empty"
             Callable[
-                [list], pd.Series,
+                [list],
+                pd.Series,
             ],  # The first lambda function: takes a list and returns a pd.Series of booleans
             Callable[
-                [list, str], None,
+                [list, str],
+                None,
             ],  # The second lambda function: takes a list and a string, and returns nothing
         ]
     ]
-	
 
     def __init__(self, name, trud_codes_path=None):
         if trud_codes_path is not None:
diff --git a/acmc/phen.py b/acmc/phen.py
index fa94e75..dd2b6ff 100644
--- a/acmc/phen.py
+++ b/acmc/phen.py
@@ -136,7 +136,6 @@ def init(phen_dir, remote_url):
         repo.clone(git_url, phen_path)
         # open repo
         repo = git.Repo(phen_path)
-
         # check if there are any commits (new repo has no commits)
         if (
             len(repo.branches) == 0 or repo.head.is_detached
@@ -202,16 +201,23 @@ def init(phen_dir, remote_url):
         },
         "codes": [],
     }
+
     config_path = phen_path / CONFIG_FILE
     with open(config_path, "w", encoding="utf-8") as f:
         json.dump(config, f, indent=4)
 
-    # TODO: add gitignore
-
-    # Ignore all SQLite database files
-    # *.db
-    # *.sqlite
-    # *.sqlite3
+    # add git ignore
+    ignore_content = """# Ignore SQLite database files
+ *.db
+ *.sqlite3
+ 
+ # Ignore SQLite journal and metadata files
+ *.db-journal
+ *.sqlite3-journal
+ """
+    ignore_path = phen_path / ".gitignore"
+    with open(ignore_path, "w") as file:
+        file.write(ignore_content)
 
     # add to git repo and commit
     for d in DEFAULT_PHEN_DIR_LIST:
-- 
GitLab