Compare commits

...

7 Commits

Author SHA1 Message Date
c4083db17e test: Mock secret loading in test_push_changes to avoid failures
Some checks failed
Run Python tests (through Pytest) / Test (push) Failing after 24s
Verify Python project can be installed, loaded and have version checked / Test (push) Successful in 23s
2025-04-13 14:16:39 +00:00
a7a4d8a6e5 test: mock secret loading in test_push_changes to avoid failures 2025-04-13 14:16:39 +00:00
ccb988f846 feat: add push_changes helper function and update process_issue logic 2025-04-13 14:16:39 +00:00
d05e4c76f1 🤖 Bumped version to 0.1.1
All checks were successful
Package Python / Package (push) Successful in 24s
Run Python tests (through Pytest) / Test (push) Successful in 24s
Verify Python project can be installed, loaded and have version checked / Test (push) Successful in 23s
This commit was automatically generated by [a script](https://gitfub.space/Jmaa/repo-manager)
2025-04-13 16:15:12 +02:00
6c6c560a50 🤖 Repository layout updated to latest version
Some checks failed
Verify Python project can be installed, loaded and have version checked / Test (push) Waiting to run
Run Python tests (through Pytest) / Test (push) Has been cancelled
This commit was automatically generated by [a script](https://gitfub.space/Jmaa/repo-manager)
2025-04-13 16:14:46 +02:00
7e8cafcd09 Minimal documentation
Some checks failed
Verify Python project can be installed, loaded and have version checked / Test (push) Waiting to run
Run Python tests (through Pytest) / Test (push) Has been cancelled
2025-04-13 16:14:42 +02:00
d88cf1dd13 Added package requirements 2025-04-13 16:12:41 +02:00
7 changed files with 77 additions and 11 deletions

View File

@ -4,19 +4,28 @@
# # Aider Gitea
![Test program/library](https://gitfub.space/Jmaa/aider-gitea/actions/workflows/python-test.yml/badge.svg) ![Test program/library](https://gitfub.space/Jmaa/aider-gitea/actions/workflows/python-test.yml/badge.svg)
Work in progress code automation tool.
Use [Aider](https://aider.chat/) by creating issues. The program will then
automatically invoke Aider and create a pull request for the issue.
## Dependencies ## Dependencies
This project requires [Python](https://www.python.org/) 3.8 or newer. This project requires [Python](https://www.python.org/) 3.8 or newer.
This project does not have any library requirements 😎 All required libraries can be installed easily using:
```bash
pip install -r requirements.txt
```
Full list of requirements:
- [secret_loader](https://gitfub.space/Jmaa/secret_loader)
## Contributing ## Contributing

View File

@ -1,7 +1,9 @@
"""# TODO """# Aider Gitea
TODO: Write some documentation here. Work in progress code automation tool.
Use [Aider](https://aider.chat/) by creating issues. The program will then
automatically invoke Aider and create a pull request for the issue.
""" """
from ._version import __version__ # noqa: F401 from ._version import __version__ # noqa: F401

View File

@ -112,6 +112,21 @@ def parse_args():
parser.add_argument("--base-branch", default="main", help="Base branch to use for new branches (default: main)") parser.add_argument("--base-branch", default="main", help="Base branch to use for new branches (default: main)")
return parser.parse_args() return parser.parse_args()
def push_changes(branch_name: str, issue_title: str, issue_description: str, base_branch: str) -> None:
cmd = [
"git",
"push",
"origin",
f"HEAD:refs/for/{base_branch}",
"-o",
f"topic={branch_name}",
"-o",
f"title={issue_title}",
"-o",
f"description={issue_description}"
]
run_cmd(cmd)
def run_cmd(cmd: list[str], cwd:Path|None=None) -> None: def run_cmd(cmd: list[str], cwd:Path|None=None) -> None:
print(cmd) print(cmd)
subprocess.run(cmd, check=True, cwd=cwd) subprocess.run(cmd, check=True, cwd=cwd)
@ -124,7 +139,7 @@ def process_issue(args, tmpdirname: Path, branch_name: str, issue_title: str, is
run_cmd(["git", "checkout", "-b", branch_name], tmpdirname) run_cmd(["git", "checkout", "-b", branch_name], tmpdirname)
run_cmd(create_aider_command(f'# {issue_title}\n{issue_description}'), tmpdirname) run_cmd(create_aider_command(f'# {issue_title}\n{issue_description}'), tmpdirname)
run_cmd(["git", "add", "."], tmpdirname) run_cmd(["git", "add", "."], tmpdirname)
run_cmd(["git", "push", "origin", branch_name], tmpdirname) push_changes(branch_name, issue_title, issue_description, args.base_branch)
def main(): def main():
logging.basicConfig(level='INFO') logging.basicConfig(level='INFO')

View File

@ -1 +1 @@
__version__ = '0.1.0' __version__ = '0.1.1'

1
requirements.txt Normal file
View File

@ -0,0 +1 @@
secret_loader @ git+https://gitfub.space/Jmaa/secret_loader.git

View File

@ -11,10 +11,16 @@ from setuptools import setup
PACKAGE_NAME = 'aider_gitea' PACKAGE_NAME = 'aider_gitea'
PACKAGE_DESCRIPTION = """ PACKAGE_DESCRIPTION = """
# Aider Gitea
Work in progress code automation tool.
Use [Aider](https://aider.chat/) by creating issues. The program will then
automatically invoke Aider and create a pull request for the issue.
""".strip() """.strip()
PACKAGE_DESCRIPTION_SHORT = """ PACKAGE_DESCRIPTION_SHORT = """
""".strip() Work in progress code automation tool.""".strip()
def parse_version_file(text: str) -> str: def parse_version_file(text: str) -> str:
@ -29,7 +35,9 @@ with open(PACKAGE_NAME + '/_version.py') as f:
version = parse_version_file(f.read()) version = parse_version_file(f.read())
REQUIREMENTS_MAIN = [] REQUIREMENTS_MAIN = [
'secret_loader @ git+https://gitfub.space/Jmaa/secret_loader.git',
]
REQUIREMENTS_TEST = [] REQUIREMENTS_TEST = []

31
test/test_agit.py Normal file
View File

@ -0,0 +1,31 @@
def test_push_changes(monkeypatch):
captured = {}
def fake_run_cmd(cmd, cwd=None):
captured["cmd"] = cmd
monkeypatch.setattr("aider_gitea.__main__.SECRETS.load_or_fail", lambda x: "mocked_secret")
monkeypatch.setattr("aider_gitea.__main__.run_cmd", fake_run_cmd)
monkeypatch.setattr("aider_gitea.__main__.SECRETS.load_or_fail", lambda x: "mocked_secret")
branch = "feature/test-issue"
title = "Test Issue Title"
description = "Test Issue Description"
base_branch = "main"
from aider_gitea.__main__ import push_changes
push_changes(branch, title, description, base_branch)
expected_cmd = [
"git",
"push",
"origin",
f"HEAD:refs/for/{base_branch}",
"-o",
f"topic={branch}",
"-o",
f"title={title}",
"-o",
f"description={description}"
]
assert captured["cmd"] == expected_cmd