diff --git a/.gitignore b/.gitignore
index 43ff6ce..cc4e628 100644
--- a/.gitignore
+++ b/.gitignore
/.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
+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
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)
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
{% 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 %}