Ticket #735: List branches in repo

ticket-769
Vadim vtroshchinskiy 2024-09-12 16:42:45 +02:00
parent 611b8e354e
commit 4e3c0a88f0
2 changed files with 22 additions and 0 deletions

View File

@ -1,6 +1,7 @@
from flask import Flask, jsonify
import os.path
import os
import git
repositories_base_path = "/opt/opengnsys/images"
@ -32,6 +33,24 @@ def get_repositories():
"repositories": repos
})
@app.route('/repositories/<repo>/branches')
def get_repository_branches(repo):
gitRepo = git.Repo(os.path.join(repositories_base_path, repo + ".git"))
branches = []
for branch in gitRepo.branches:
branches = branches + [branch.name]
return jsonify({
"branches": branches
})
# Define a route for health check
@app.route('/health')
def health_check():

View File

@ -1,11 +1,14 @@
click==8.0.4
dataclasses==0.8
Flask==2.0.3
gitdb==4.0.9
GitPython==3.1.20
importlib-metadata==4.8.3
itsdangerous==2.0.1
Jinja2==3.0.3
MarkupSafe==2.0.1
pkg-resources==0.0.0
smmap==5.0.0
typing-extensions==4.1.1
Werkzeug==2.0.3
zipp==3.6.0