Skip to content

Commit f5331d9

Browse files
committed
test: verify automatic git commit
1 parent 00aed6a commit f5331d9

30 files changed

Lines changed: 183 additions & 6 deletions

.env

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
LEETCODE_SESSION=
1+
LEETCODE_SESSION=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfYXV0aF91c2VyX2lkIjoiMTI5ODI3MzMiLCJfYXV0aF91c2VyX2JhY2tlbmQiOiJhbGxhdXRoLmFjY291bnQuYXV0aF9iYWNrZW5kcy5BdXRoZW50aWNhdGlvbkJhY2tlbmQiLCJfYXV0aF91c2VyX2hhc2giOiI4NGE5ZTQ0YmU0ZWQ3NjQzOThmNWMwZjBkZDViOGE4ZGZkOWZmYjE5Njg2YTNlMWZmZTE4OTZhMmMyOTQ5YTBiIiwic2Vzc2lvbl91dWlkIjoiMjg2ODI2ZDYiLCJpZCI6MTI5ODI3MzMsImVtYWlsIjoicmFqamFybmF2QGdtYWlsLmNvbSIsInVzZXJuYW1lIjoicmFqamFybmF2IiwidXNlcl9zbHVnIjoicmFqamFybmF2IiwiYXZhdGFyIjoiaHR0cHM6Ly9hc3NldHMubGVldGNvZGUuY29tL3VzZXJzL3Jhamphcm5hdi9hdmF0YXJfMTc0MDQxMTAzMy5wbmciLCJyZWZyZXNoZWRfYXQiOjE3ODI4NzY4MzYsImlwIjoiMjQwOTo0MGU0OjZlOjUwNTI6NzBhNDoyODc3OmYxOWM6ZGE3OSIsImlkZW50aXR5IjoiMTZmZWUzNzU1OWRiZDQyYjQ0ODIwNDQ0NmQwMjA4OWYiLCJkZXZpY2Vfd2l0aF9pcCI6WyJjYTc3MWEzNmNhNjA5NzJhYjA4NzU1ZWVlMDA3MzUzZCIsIjI0MDk6NDBlNDo2ZTo1MDUyOjcwYTQ6Mjg3NzpmMTljOmRhNzkiXX0.yZNj861870yrKRZQ5WxoFO336W29dcX0ZkbNlp0bkWc
22

3-
CSRF_TOKEN=
3+
CSRF_TOKEN=eKyI0IvuBIkDJBAYY7T2rsaSv5KNMEJn
44

55
GITHUB_USERNAME=arnav-on-code
66

7-
GITHUB_EMAIL= rajjarnav@gmail.com
7+
GITHUB_EMAIL= rajjarnav@gmail.com
8+
9+
LEETCODE_USERNAME= arnav-on-code

.github/workflows/lint.yml

Whitespace-only changes.

.github/workflows/tests.yml

Whitespace-only changes.

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.myenv/
2+
.env
3+
__pycache__/
4+
*.pyc
5+
logs/
6+
.vscode/
7+
.idea/

github_sync/manager.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from pathlib import Path
2+
import subprocess
3+
4+
5+
class GitManager:
6+
"""
7+
Handles Git operations for the repository.
8+
"""
9+
10+
def __init__(self, repository: Path):
11+
self.repository = Path(repository)
12+
13+
def run(self, *args):
14+
"""
15+
Execute a git command inside the repository.
16+
"""
17+
18+
result = subprocess.run(
19+
["git", *args],
20+
cwd=self.repository,
21+
capture_output=True,
22+
text=True,
23+
)
24+
25+
if result.returncode != 0:
26+
raise RuntimeError(result.stderr.strip())
27+
28+
return result.stdout.strip()
29+
30+
def status(self):
31+
return self.run("status", "--short")
32+
33+
def add(self):
34+
self.run("add", ".")
35+
36+
def commit(self, message: str):
37+
self.run("commit", "-m", message)
38+
39+
def push(self):
40+
self.run("push")
41+
42+
def pull(self):
43+
self.run("pull")

github_sync/statistics.py

Whitespace-only changes.

leetcode/constants.py

Whitespace-only changes.

leetcode/exceptions.py

Whitespace-only changes.

main.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44

55
from sync.detector import SubmissionDetector
66

7-
87
from leetcode.auth import LeetCodeAuth
98
from leetcode.client import LeetCodeClient
109
from leetcode.api import LeetCodeAPI
10+
1111
from config.settings import Config
1212

1313
from leetcode.downloader import SubmissionDownloader
1414

15+
from github_sync.manager import GitManager
1516

1617
console = Console()
1718

@@ -136,8 +137,6 @@ def main():
136137
}
137138
console.print(f"Status : {STATUS_MAP.get(detail.status_code, 'Unknown')}")
138139

139-
detail = api.get_submission_detail(submissions[0].id)
140-
141140
downloader = SubmissionDownloader()
142141

143142
folder = downloader.download(detail)
@@ -146,5 +145,25 @@ def main():
146145
f"\n[bold green]Solution saved:[/bold green]\n{folder}"
147146
)
148147

148+
git = GitManager(Config.BASE_DIR)
149+
150+
console.print("\n[bold cyan]Git Status Before[/bold cyan]")
151+
console.print(git.status())
152+
153+
git.add()
154+
155+
console.print("\n[bold green]Files staged successfully.[/bold green]")
156+
157+
console.print("\n[bold cyan]Git Status After[/bold cyan]")
158+
console.print(git.status())
159+
160+
git.commit(
161+
"test: verify automatic git commit"
162+
)
163+
164+
console.print("[green]Commit successful![/green]")
165+
166+
167+
149168
if __name__ == "__main__":
150169
main()

storage/cache.json

Whitespace-only changes.

0 commit comments

Comments
 (0)