@jswork/ushell-module-git 1.0.50 → 1.0.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.sh CHANGED
@@ -89,6 +89,7 @@ alias ggt="${ROOT_PATH}/modules/03-quick-tag.sh"
89
89
  alias fixup="${ROOT_PATH}/modules/10-fixup.sh"
90
90
  alias git-reset="${ROOT_PATH}/modules/04-reset-git.sh"
91
91
  alias git-clean="${ROOT_PATH}/modules/06-git-clean.sh"
92
+ alias rmb="${ROOT_PATH}/modules/13-del-branch.sh"
92
93
 
93
94
 
94
95
  # check git repo size
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # 检查是否提供了分支名称作为第一个参数
4
+ if [ -z "$1" ]; then
5
+ echo "Usage: $0 <branch_name> [default_branch]"
6
+ exit 1
7
+ fi
8
+
9
+ # 获取分支名称和默认分支名称
10
+ BRANCH_NAME=$1
11
+ DEFAULT_BRANCH=${2:-main} # 如果没有提供第二个参数,默认为 main
12
+
13
+ # 切换到默认分支
14
+ echo "Switching to default branch ($DEFAULT_BRANCH)..."
15
+ git checkout $DEFAULT_BRANCH || { echo "Failed to switch to $DEFAULT_BRANCH branch"; exit 1; }
16
+
17
+ # 检查本地分支是否存在
18
+ if git show-ref --quiet --verify refs/heads/$BRANCH_NAME; then
19
+ echo "Deleting local branch ($BRANCH_NAME)..."
20
+ git branch -D $BRANCH_NAME || { echo "Failed to delete local branch $BRANCH_NAME"; exit 1; }
21
+ else
22
+ echo "Local branch '$BRANCH_NAME' does not exist. Skipping local deletion."
23
+ fi
24
+
25
+ # 删除远程分支
26
+ echo "Deleting remote branch ($BRANCH_NAME)..."
27
+ git push origin --delete $BRANCH_NAME || { echo "Failed to delete remote branch $BRANCH_NAME"; exit 1; }
28
+
29
+ echo "Branch '$BRANCH_NAME' has been successfully deleted locally and remotely."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jswork/ushell-module-git",
3
- "version": "1.0.50",
3
+ "version": "1.0.52",
4
4
  "description": "Unix like shell module for git.",
5
5
  "main": "index.sh",
6
6
  "repository": {