From a65da0e848c4b45495129b160169894e1cffdb35 Mon Sep 17 00:00:00 2001 From: zeeland Date: Tue, 23 Jul 2024 21:40:47 +0800 Subject: [PATCH] feat: Add 'ac' alias for combined add and commit --- README.md | 12 +++++++++++- gcop/__main__.py | 10 ++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0328b92..f48eb6d 100644 --- a/README.md +++ b/README.md @@ -59,11 +59,13 @@ GitHub: https://github.com/Undertone0809/gcop Usage: git [OPTIONS] COMMAND Commands: - git undo Undo the last commit but keep the file changes + git p Push the changes to the remote repository git pf Push the changes to the remote repository with force + git undo Undo the last commit but keep the file changes git ghelp Add command into git config git gconfig Open the config file in the default editor git gcommit Generate a git commit message based on the staged changes and commit the changes + git ac The same as `git add . && git gcommit` command git c The same as `git gcommit` command ``` @@ -124,6 +126,14 @@ Undo the last commit. Push force to the current branch, equivalent to `git push --force`. +### git p + +Push to the current branch, equivalent to `git push`. + +### git ac + +The same as `git add . && git gcommit` command. + ## Development setup Conda package manager is recommended. Create a conda environment. diff --git a/gcop/__main__.py b/gcop/__main__.py index 5a4eb5d..357c611 100644 --- a/gcop/__main__.py +++ b/gcop/__main__.py @@ -136,12 +136,12 @@ def init_command(): encoding="utf-8", # noqa ) subprocess.run( - ["git", "config", "--global", "alias.undo", "reset --soft HEAD^"], + ["git", "config", "--global", "alias.pf", "push --force"], check=True, encoding="utf-8", # noqa ) subprocess.run( - ["git", "config", "--global", "alias.pf", "push --force"], + ["git", "config", "--global", "alias.undo", "reset --soft HEAD^"], check=True, encoding="utf-8", # noqa ) @@ -155,6 +155,11 @@ def init_command(): check=True, encoding="utf-8", # noqa ) + subprocess.run( + ["git", "config", "--global", "alias.ac", "!git add . && gcop commit"], + check=True, + encoding="utf-8", # noqa + ) subprocess.run( ["git", "config", "--global", "alias.gconfig", "!gcop config"], check=True, @@ -230,6 +235,7 @@ def help_command(): git ghelp Add command into git config git gconfig Open the config file in the default editor git gcommit Generate a git commit message based on the staged changes and commit the changes + git ac The same as `git add . && git gcommit` command git c The same as `git gcommit` command """ # noqa