From 345e3e9c3ca01f4db1cda57a139f3cb17073cff2 Mon Sep 17 00:00:00 2001 From: Avi Avni Date: Wed, 5 Mar 2025 15:48:33 +0200 Subject: [PATCH 1/2] add list commits --- api/index.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/api/index.py b/api/index.py index 3f7c50b..50b17c7 100644 --- a/api/index.py +++ b/api/index.py @@ -7,6 +7,7 @@ from api.analyzers.source_analyzer import SourceAnalyzer from api.git_utils import git_utils +from api.git_utils.git_graph import GitGraph from api.graph import Graph, get_repos, graph_exists from api.info import get_repo_info from api.llm import ask @@ -448,3 +449,41 @@ def switch_commit(): } return jsonify(response), 200 + +@app.route('/list_commits', methods=['POST']) +@public_access # Apply public access decorator +@token_required # Apply token authentication decorator +def list_commits(): + """ + Endpoint to list all commits of a specified repository. + + Request JSON Structure: + { + "repo": "repository_name" + } + + Returns: + JSON response with a list of commits or an error message. + """ + + # Get JSON data from the request + data = request.get_json() + + # Validate the presence of the 'repo' parameter + repo = data.get('repo') + if repo is None: + return jsonify({'status': f'Missing mandatory parameter "repo"'}), 400 + + # Initialize GitGraph object to interact with the repository + git_graph = GitGraph(git_utils.GitRepoName(repo)) + + # Fetch commits from the repository + commits = git_graph.list_commits() + + # Return success response with the list of commits + response = { + 'status': 'success', + 'commits': commits + } + + return jsonify(response), 200 \ No newline at end of file From 42d13df85e86be5a4a1e8698d3e124ad0bdd260d Mon Sep 17 00:00:00 2001 From: Avi Avni Date: Wed, 5 Mar 2025 15:48:48 +0200 Subject: [PATCH 2/2] bump version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index cc2bd29..b817a1f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "code-graph-backend" -version = "0.4.1" +version = "0.4.2" description = "code_graph is designed to help developers visualize and analyze the structure of their source code. It takes source code as input and generates a graph representation, making it easier to understand relationships and dependencies within the codebase." authors = ["Roi Lipman "] readme = "README.md"