-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_commit.py
More file actions
128 lines (97 loc) · 3.46 KB
/
Copy pathtest_commit.py
File metadata and controls
128 lines (97 loc) · 3.46 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/usr/bin/env python3
"""
Auto Commit Tool 테스트 스크립트
"""
import os
import sys
from pathlib import Path
# 현재 디렉토리를 Python 경로에 추가
sys.path.insert(0, str(Path(__file__).parent))
from auto_commit import CommitGPT, AutoCommitter
def test_commit_gpt():
"""CommitGPT 클래스 테스트"""
print("=== CommitGPT 테스트 ===")
# CommitGPT 초기화
commit_gpt = CommitGPT()
# 설정 확인
print(f"기본 모델: {commit_gpt.model_name}")
print(f"설정 로드됨: {bool(commit_gpt.config)}")
# 모델 로드 테스트 (드라이 런)
print("\n모델 로드 테스트...")
try:
commit_gpt.load_model()
print("✅ 모델 로드 성공")
except Exception as e:
print(f"❌ 모델 로드 실패: {e}")
# 프롬프트 생성 테스트
print("\n프롬프트 생성 테스트...")
test_diff = """
diff --git a/test.py b/test.py
index 1234567..abcdefg 100644
--- a/test.py
+++ b/test.py
@@ -1,3 +1,5 @@
def hello():
- print("Hello")
+ print("Hello, World!")
+ return True
"""
test_context = {"branch": "main", "changed_files": ["test.py"]}
prompt = commit_gpt._build_prompt(test_diff, test_context)
print(f"생성된 프롬프트 길이: {len(prompt)}")
print("프롬프트 미리보기:")
print(prompt[:200] + "...")
def test_auto_committer():
"""AutoCommitter 클래스 테스트"""
print("\n=== AutoCommitter 테스트 ===")
# AutoCommitter 초기화
committer = AutoCommitter()
# 저장소 초기화 테스트
print("저장소 초기화 테스트...")
if committer.initialize_repo():
print("✅ Git 저장소 로드 성공")
# 변경사항 확인
has_changes = committer.check_changes()
print(f"변경사항 존재: {has_changes}")
if has_changes:
print("변경사항이 있습니다. 실제 커밋을 테스트하려면:")
print("python auto_commit.py --dry-run")
else:
print("커밋할 변경사항이 없습니다.")
else:
print("❌ Git 저장소 로드 실패")
print("현재 디렉토리가 Git 저장소인지 확인하세요.")
def test_config():
"""설정 파일 테스트"""
print("\n=== 설정 파일 테스트 ===")
config_path = Path(__file__).parent / "config.json"
if config_path.exists():
print("✅ 설정 파일 존재")
import json
with open(config_path, "r", encoding="utf-8") as f:
config = json.load(f)
print(
f"사용 가능한 모델 수: {len(config.get('models', {}).get('available', []))}"
)
print(f"기본 모델: {config.get('models', {}).get('default', 'N/A')}")
print(f"생성 파라미터: {config.get('generation', {})}")
else:
print("❌ 설정 파일이 없습니다")
def main():
"""메인 테스트 함수"""
print("Auto Commit Tool 테스트 시작\n")
try:
test_config()
test_commit_gpt()
test_auto_committer()
print("\n=== 테스트 완료 ===")
print("\n사용법:")
print("1. 기본 사용: python auto_commit.py")
print("2. 드라이 런: python auto_commit.py --dry-run")
print("3. 모델 목록: python auto_commit.py --list-models")
except Exception as e:
print(f"\n❌ 테스트 중 오류 발생: {e}")
import traceback
traceback.print_exc()
if __name__ == "__main__":
main()