Skip to content

Commit 2d71c19

Browse files
authored
Merge pull request #84 from FalkorDB/add-list-commits
Add list commits
2 parents 0c40e43 + 42d13df commit 2d71c19

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

Diff for: api/index.py

+39
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from api.analyzers.source_analyzer import SourceAnalyzer
99
from api.git_utils import git_utils
10+
from api.git_utils.git_graph import GitGraph
1011
from api.graph import Graph, get_repos, graph_exists
1112
from api.info import get_repo_info
1213
from api.llm import ask
@@ -448,3 +449,41 @@ def switch_commit():
448449
}
449450

450451
return jsonify(response), 200
452+
453+
@app.route('/list_commits', methods=['POST'])
454+
@public_access # Apply public access decorator
455+
@token_required # Apply token authentication decorator
456+
def list_commits():
457+
"""
458+
Endpoint to list all commits of a specified repository.
459+
460+
Request JSON Structure:
461+
{
462+
"repo": "repository_name"
463+
}
464+
465+
Returns:
466+
JSON response with a list of commits or an error message.
467+
"""
468+
469+
# Get JSON data from the request
470+
data = request.get_json()
471+
472+
# Validate the presence of the 'repo' parameter
473+
repo = data.get('repo')
474+
if repo is None:
475+
return jsonify({'status': f'Missing mandatory parameter "repo"'}), 400
476+
477+
# Initialize GitGraph object to interact with the repository
478+
git_graph = GitGraph(git_utils.GitRepoName(repo))
479+
480+
# Fetch commits from the repository
481+
commits = git_graph.list_commits()
482+
483+
# Return success response with the list of commits
484+
response = {
485+
'status': 'success',
486+
'commits': commits
487+
}
488+
489+
return jsonify(response), 200

Diff for: pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "code-graph-backend"
3-
version = "0.4.1"
3+
version = "0.4.2"
44
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."
55
authors = ["Roi Lipman <[email protected]>"]
66
readme = "README.md"

0 commit comments

Comments
 (0)