diff --git a/api/gitapi.py b/api/gitapi.py index 7b1ae58..071221f 100644 --- a/api/gitapi.py +++ b/api/gitapi.py @@ -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//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(): diff --git a/api/requirements.txt b/api/requirements.txt index 90ab8a2..8e7eab4 100644 --- a/api/requirements.txt +++ b/api/requirements.txt @@ -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