Diff between e510aacc5783a8b1e5c01fba07fcca191c81b0c2 and ad8641ac4b4914c58310bb6bf8dad5ac26319a56

Changed Files

File Additions Deletions Status
.gitignore +2 -1 modified
git/db.py +22 -0 added
git/repo.py +7 -1 modified
templates/index.html +2 -2 modified

Full Patch

diff --git a/.gitignore b/.gitignore
index 43ff6ce..cc4e628 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
 /.venv
 __pycache__/
-.env
\ No newline at end of file
+.env
+*.db
\ No newline at end of file
diff --git a/git/db.py b/git/db.py
new file mode 100644
index 0000000..84e9510
--- /dev/null
+++ b/git/db.py
@@ -0,0 +1,22 @@
+import sqlite3
+
+def init_db(db_path):
+    conn = sqlite3.connect(db_path)
+    cursor = conn.cursor()
+    cursor.execute('''
+        CREATE TABLE IF NOT EXISTS repos (
+            id INTEGER PRIMARY KEY,
+            name TEXT UNIQUE,
+            owner TEXT
+        )
+    ''')
+    conn.commit()
+    conn.close()
+
+def get_owner(db_path, repo_name):
+    conn = sqlite3.connect(db_path)
+    cursor = conn.cursor()
+    cursor.execute('SELECT owner FROM repos WHERE name = ?', (repo_name,))
+    row = cursor.fetchone()
+    conn.close()
+    return row[0] if row else None
\ No newline at end of file
diff --git a/git/repo.py b/git/repo.py
index 0568a81..540f94e 100644
--- a/git/repo.py
+++ b/git/repo.py
@@ -1,9 +1,13 @@
 from pathlib import Path
 import pygit2 as git
+import os
+from .db import init_db, get_owner
 
 # scans given path for bare git repos and list their names and paths
 def get_bare_repos(path):
     repos = []
+    db_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'lipasto.db')
+    init_db(db_path)
 
     repo_path = Path(path)
 
@@ -19,10 +23,12 @@ def get_bare_repos(path):
                             description = desc_file.read_text().strip()
                         except:
                             pass
+                    owner = get_owner(db_path, item.name)
                     repo_info = {
                         "name": item.name,
                         "path": str(item.resolve()),
-                        "description": description
+                        "description": description,
+                        "owner": owner
                     }
                     repos.append(repo_info)
             except git.GitError:
diff --git a/templates/index.html b/templates/index.html
index b2bbbc2..bb411b0 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -32,8 +32,8 @@
                 {% for repo in repos %}
                     <div class="repo-card">
                         <h4><a href="{{ url_for('repo_detail', repo_name=repo.name) }}">{{ repo.name }}</a></h4>
-                        {% if repo.description %}
-                            <p>{{ repo.description }}</p>
+                        {% if repo.owner %}
+                            <p>{{ repo.owner }}</p>
                         {% else %}
                             <p>-</p>
                         {% endif %}