Diff between 97f4325e0f1f40a6918ceadd420c839b222edd20 and 1e9fb20d7cdd9581bdbc9233f5c36a2160ac3f44

Changed Files

File Additions Deletions Status
app.py +6 -0 modified
git/ref.py +12 -0 added
templates/refs.html +10 -0 added

Full Patch

diff --git a/app.py b/app.py
index c7210b0..a05ebd4 100644
--- a/app.py
+++ b/app.py
@@ -2,6 +2,7 @@ from flask import Flask, render_template, request
 
 from git.repo import get_bare_repos
 from git.commit import get_commits, get_commit
+from git.ref import get_refs
 
 app = Flask(__name__)
 
@@ -23,5 +24,10 @@ def commit_detail(repo_name, commit_hash):
     commit = get_commit(f"{repo_path}/{repo_name}", commit_hash)
     return render_template("commit.html", repo_name=repo_name, commit=commit)
 
+@app.route("/<repo_name>/refs")
+def repo_refs(repo_name):
+    refs = get_refs(f"{repo_path}/{repo_name}")
+    return render_template("refs.html", repo_name=repo_name, refs=refs)
+
 if __name__ == "__main__":
     app.run(debug=True)
\ No newline at end of file
diff --git a/git/ref.py b/git/ref.py
new file mode 100644
index 0000000..4e21555
--- /dev/null
+++ b/git/ref.py
@@ -0,0 +1,12 @@
+import pygit2 as git
+
+def get_refs(path):
+    repo = git.Repository(path)
+    refs = []
+    for ref_name in repo.listall_references():
+        ref = repo.lookup_reference(ref_name)
+        refs.append({
+            'name': ref.name,
+            'target': str(ref.target)
+        })
+    return refs
\ No newline at end of file
diff --git a/templates/refs.html b/templates/refs.html
new file mode 100644
index 0000000..f4b8af2
--- /dev/null
+++ b/templates/refs.html
@@ -0,0 +1,10 @@
+{% block content %}
+    <h1>Refs for {{ repo_name }}</h1>
+    <ul>
+        {% for ref in refs %}
+            <li>
+            {{ ref.name }} - {{ ref.target }}
+            </li>
+        {% endfor %}
+    </ul>
+{% endblock %}
\ No newline at end of file