Skip to content

Commit

Permalink
feat: Add 'ac' alias for combined add and commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Undertone0809 committed Jul 23, 2024
1 parent 63ce8c0 commit a65da0e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down Expand Up @@ -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.
Expand Down
10 changes: 8 additions & 2 deletions gcop/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand All @@ -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,
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit a65da0e

Please sign in to comment.