From bd77cd3676cf5f7fb0782c94c838b40def96ec11 Mon Sep 17 00:00:00 2001 From: Adwaith-Rajesh Date: Tue, 19 Aug 2025 22:30:59 +0530 Subject: [PATCH] fix #2 [chore] removed onedev buildscpec [fix] use subprocess instead of execvp using execvp means that we have to add the messages before git-add switching to subprocess allows us to check whether git-add was successfull and if it was, then add the message. ondev buildspec was removed as we have switched to gittea --- .onedev-buildspec.yml | 35 ----------------------------------- git_changes.py | 13 +++++++++---- 2 files changed, 9 insertions(+), 39 deletions(-) delete mode 100644 .onedev-buildspec.yml diff --git a/.onedev-buildspec.yml b/.onedev-buildspec.yml deleted file mode 100644 index 5da95f3..0000000 --- a/.onedev-buildspec.yml +++ /dev/null @@ -1,35 +0,0 @@ -version: 39 -jobs: -- name: Upload to Pypi - steps: - - !CheckoutStep - name: Checkout Code - cloneCredential: !DefaultCredential {} - withLfs: false - withSubmodules: false - cloneDepth: 1 - condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL - - !CommandStep - name: Publish to Pypi - runInContainer: true - image: python:3.12-bullseye - interpreter: !DefaultInterpreter - commands: | - cat << EOF > $HOME/.pypirc - [pypi] - username=__token__ - password=@secret:access-token@ - EOF - - pip3 install build twine - python3 -m build - python3 -m twine upload dist/* - useTTY: true - condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL - triggers: - - !TagCreateTrigger - branches: dev - retryCondition: never - maxRetries: 3 - retryDelay: 30 - timeout: 14400 diff --git a/git_changes.py b/git_changes.py index ce99eea..cbcb7b4 100644 --- a/git_changes.py +++ b/git_changes.py @@ -4,9 +4,9 @@ import argparse import configparser import os import stat +import subprocess import sys from pathlib import Path -from typing import NoReturn GIT_DIR = Path('.git') @@ -77,16 +77,21 @@ def _reset_commit_msg_file() -> None: GIT_COMMIT_MSG_FILE.write_text('') -def git_add() -> NoReturn: +def _run_git_add(args: list[str]) -> int: + git_add = subprocess.run(['git', 'add', *args]) + return git_add.returncode + + +def git_add() -> int: add_parser = argparse.ArgumentParser() add_parser.add_argument('-m', '--message', required=True, help='Message to add') add_parser.add_argument('--type', choices=COMMIT_TYPES, default='feat', help='The type of the change') args, rest = add_parser.parse_known_args() - if args.message: + if args.message and (_run_git_add(rest) == 0): print(_add_msg_to_file(args.message, args.type)) - os.execvp('git', ('git', 'add', *rest)) + return 0 def show_messages() -> int: