-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_selection_logic.py
More file actions
53 lines (41 loc) · 1.89 KB
/
test_selection_logic.py
File metadata and controls
53 lines (41 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python3
"""
Test script to verify the updated commit/branch selection logic.
"""
import os
from git_repository_manager import GitRepository, GitCommit, GitBranch
def test_selection_logic():
"""Test the different selection behaviors"""
# Test with the current repository
current_repo_path = os.getcwd()
print(f"Testing selection logic with repository: {current_repo_path}")
# Create a GitRepository instance
repo = GitRepository(current_repo_path)
print("\n1. Testing repository selection (should show commits):")
try:
current_branch, commits = repo.get_current_branch_commits(5)
print(f" Current branch: {current_branch}")
print(f" Found {len(commits)} commits:")
for i, commit in enumerate(commits, 1):
print(f" {i}. {commit.commit_sha[:8]} - {commit.message[:50]}")
if commit.branch_names:
print(f" Branch heads: {commit.get_branch_names_display()}")
except Exception as e:
print(f" Error: {e}")
print("\n2. Testing local branch selection (should show branches):")
try:
repo.load_branches()
print(f" Found {len(repo.local_branches)} local branches:")
for i, branch in enumerate(repo.local_branches[:5], 1):
print(f" {i}. {branch.name} - {branch.commit_sha[:8]}")
except Exception as e:
print(f" Error: {e}")
print("\n3. Testing remote branch selection (should show branches):")
try:
print(f" Found {len(repo.remote_branches)} remote branches:")
for i, branch in enumerate(repo.remote_branches[:5], 1):
print(f" {i}. {branch.name} - {branch.commit_sha[:8]}")
except Exception as e:
print(f" Error: {e}")
if __name__ == "__main__":
test_selection_logic()