@san-siva/gitsy 1.0.0 → 1.0.2
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/README.md +194 -26
- package/{g-cb → bin/g-cb} +12 -2
- package/{g-co → bin/g-co} +13 -2
- package/{g-db → bin/g-db} +21 -7
- package/{g-diff → bin/g-diff} +28 -11
- package/{g-dlc → bin/g-dlc} +15 -4
- package/{g-pull → bin/g-pull} +10 -4
- package/{g-push → bin/g-push} +12 -4
- package/{g-rmf → bin/g-rmf} +10 -1
- package/{g-rto → bin/g-rto} +11 -2
- package/{g-s → bin/g-s} +11 -2
- package/bin/g-wa +403 -0
- package/{g-wr → bin/g-wr} +85 -73
- package/{utils → bin/utils} +165 -38
- package/package.json +16 -28
- package/g-wa +0 -155
package/README.md
CHANGED
|
@@ -1,53 +1,221 @@
|
|
|
1
1
|
# gitsy
|
|
2
2
|
|
|
3
|
+

|
|
3
4
|
A set of bash utilities for managing Git repositories with ease. Provides user-friendly commands with helpful prompts, color-coded outputs, and automation.
|
|
4
5
|
|
|
6
|
+
## Documentation
|
|
7
|
+
|
|
8
|
+
For complete documentation, usage examples, and detailed command reference, visit the [gitsy documentation website](https://gitsy-56895.web.app).
|
|
9
|
+
|
|
10
|
+
## System Requirements
|
|
11
|
+
|
|
12
|
+
- Node.js >= 12.0.0
|
|
13
|
+
- Bash shell
|
|
14
|
+
- Git
|
|
15
|
+
- Supported OS: macOS, Linux
|
|
16
|
+
|
|
5
17
|
## Available Commands
|
|
6
18
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
| Command | Description |
|
|
20
|
+
|---------|-------------|
|
|
21
|
+
| `g-s` | Show git status with colorful output |
|
|
22
|
+
| `g-cb` | Display current branch name |
|
|
23
|
+
| `g-co` | Checkout branch with optional stashing |
|
|
24
|
+
| `g-pull` | Pull changes from remote branch |
|
|
25
|
+
| `g-push` | Push changes to remote (supports force push) |
|
|
26
|
+
| `g-wa` | Create git worktree with automatic repository restructuring |
|
|
27
|
+
| `g-wr` | Remove git worktree |
|
|
28
|
+
| `g-db` | Delete branch locally and remotely |
|
|
29
|
+
| `g-dlc` | Discard last commit |
|
|
30
|
+
| `g-rmf` | Stash working directory changes |
|
|
31
|
+
| `g-rto` | Reset to remote branch |
|
|
32
|
+
| `g-diff` | Compare changes between branches |
|
|
19
33
|
|
|
20
34
|
## Installation
|
|
21
35
|
|
|
36
|
+
Install gitsy globally with npm:
|
|
37
|
+
|
|
22
38
|
```bash
|
|
23
|
-
|
|
24
|
-
|
|
39
|
+
npm install -g gitsy
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
That's it! All commands (`g-s`, `g-co`, `g-pull`, etc.) will be available immediately.
|
|
25
43
|
|
|
26
|
-
|
|
27
|
-
|
|
44
|
+
### Prerequisites
|
|
45
|
+
|
|
46
|
+
You'll also need these dependencies installed:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
# macOS
|
|
50
|
+
brew install git figlet lolcat
|
|
51
|
+
|
|
52
|
+
# Ubuntu/Debian
|
|
53
|
+
sudo apt-get install git figlet lolcat
|
|
54
|
+
|
|
55
|
+
# Fedora/RHEL
|
|
56
|
+
sudo dnf install git figlet lolcat
|
|
28
57
|
```
|
|
29
58
|
|
|
30
|
-
|
|
59
|
+
### Verify Installation
|
|
31
60
|
|
|
32
|
-
|
|
61
|
+
```bash
|
|
62
|
+
g-s --help
|
|
63
|
+
```
|
|
33
64
|
|
|
34
|
-
|
|
65
|
+
### Troubleshooting
|
|
66
|
+
|
|
67
|
+
**Commands not found:**
|
|
68
|
+
- Ensure npm global bin directory is in your PATH
|
|
69
|
+
- Try: `npm uninstall -g gitsy && npm install -g gitsy`
|
|
70
|
+
|
|
71
|
+
**Missing dependencies:**
|
|
72
|
+
- Verify with: `git --version`, `figlet --version`, `lolcat --version`
|
|
73
|
+
|
|
74
|
+
**Permission errors:**
|
|
75
|
+
- Use `sudo npm install -g gitsy` on some systems
|
|
76
|
+
- Or configure npm user directory: `npm config set prefix ~/.npm-global`
|
|
77
|
+
|
|
78
|
+
## Usage
|
|
79
|
+
|
|
80
|
+
All gitsy commands support the `--help` flag for detailed usage information:
|
|
35
81
|
|
|
36
|
-
Quick start:
|
|
37
82
|
```bash
|
|
38
|
-
# Run any command with --help to see available options
|
|
39
83
|
g-co --help
|
|
40
84
|
```
|
|
41
85
|
|
|
86
|
+
### Quick Examples
|
|
87
|
+
|
|
88
|
+
**Check git status:**
|
|
89
|
+
```bash
|
|
90
|
+
g-s
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**Checkout a branch:**
|
|
94
|
+
```bash
|
|
95
|
+
g-co -t feature-branch
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Create a new worktree:**
|
|
99
|
+
```bash
|
|
100
|
+
g-wa -t new-feature
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Understanding g-wa: Worktree Management
|
|
104
|
+
|
|
105
|
+
`g-wa` intelligently manages git worktrees with automatic repository restructuring:
|
|
106
|
+
|
|
107
|
+
**First-time setup:**
|
|
108
|
+
- Automatically detects if your repository needs restructuring
|
|
109
|
+
- Moves your repository into a `main` subdirectory
|
|
110
|
+
- Creates a `worktrees` directory for branch isolation
|
|
111
|
+
- Provides clear step-by-step feedback throughout the process
|
|
112
|
+
|
|
113
|
+
**Structure after setup:**
|
|
114
|
+
```
|
|
115
|
+
your-repo/
|
|
116
|
+
├── main/ # Your default branch (main/master)
|
|
117
|
+
└── worktrees/ # All feature branch worktrees
|
|
118
|
+
├── feature_1/
|
|
119
|
+
├── feature_2/
|
|
120
|
+
└── bugfix_abc/
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**Key features:**
|
|
124
|
+
- Only creates worktrees from the default branch (main/master)
|
|
125
|
+
- Automatically sanitizes branch names for directory creation
|
|
126
|
+
- Converts paths to absolute paths for clarity
|
|
127
|
+
- Checks for existing worktrees to prevent duplicates
|
|
128
|
+
- Prompts to create new branches if they don't exist
|
|
129
|
+
- Automatically pushes new branches to remote
|
|
130
|
+
|
|
131
|
+
**Pull latest changes:**
|
|
132
|
+
```bash
|
|
133
|
+
g-pull
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
**Push changes to remote:**
|
|
137
|
+
```bash
|
|
138
|
+
g-push
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**Compare branches:**
|
|
142
|
+
```bash
|
|
143
|
+
g-diff -s main -t feature-branch
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
For complete command documentation and advanced usage examples, visit the [gitsy documentation website](https://gitsy-56895.web.app).
|
|
147
|
+
|
|
148
|
+
## Features
|
|
149
|
+
|
|
150
|
+
- **Interactive prompts** - User-friendly command-line prompts guide you through operations
|
|
151
|
+
- **Color-coded output** - Easy-to-read, colorful terminal output powered by lolcat
|
|
152
|
+
- **Safety checks** - Built-in validations prevent common git mistakes
|
|
153
|
+
- **Automation** - Streamlines complex git workflows into single commands
|
|
154
|
+
- **Intelligent worktree management** - Automatic repository restructuring for seamless worktree workflows
|
|
155
|
+
- **Branch operations** - Quick branch switching, creation, and deletion
|
|
156
|
+
- **Step-by-step feedback** - Clear progress indicators show exactly what's happening
|
|
157
|
+
|
|
42
158
|
## Contributing
|
|
43
159
|
|
|
44
|
-
Contributions are welcome!
|
|
160
|
+
Contributions are welcome! Here's how to contribute:
|
|
161
|
+
|
|
162
|
+
### Development Setup
|
|
163
|
+
|
|
164
|
+
1. **Fork and clone** the repository:
|
|
165
|
+
```bash
|
|
166
|
+
git clone https://github.com/YOUR_USERNAME/gitsy.git
|
|
167
|
+
cd gitsy
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
2. **Install dependencies** (git, figlet, lolcat)
|
|
171
|
+
|
|
172
|
+
3. **Link for local development**:
|
|
173
|
+
```bash
|
|
174
|
+
npm link
|
|
175
|
+
```
|
|
176
|
+
This creates symlinks so you can test your changes globally.
|
|
177
|
+
|
|
178
|
+
4. **Create a feature branch**:
|
|
179
|
+
```bash
|
|
180
|
+
git checkout -b feature/your-feature-name
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
5. **Make your changes** and test thoroughly
|
|
184
|
+
|
|
185
|
+
6. **Validate syntax**:
|
|
186
|
+
```bash
|
|
187
|
+
npm test
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
7. **Commit and push**:
|
|
191
|
+
```bash
|
|
192
|
+
git commit -m "Description of your changes"
|
|
193
|
+
git push origin feature/your-feature-name
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
8. **Create a Pull Request** on GitHub
|
|
197
|
+
|
|
198
|
+
### Reporting Issues
|
|
199
|
+
|
|
200
|
+
Found a bug or have a feature request? Please [open an issue](https://github.com/san-siva/gitsy/issues) with:
|
|
201
|
+
- A clear description of the problem or suggestion
|
|
202
|
+
- Steps to reproduce (for bugs)
|
|
203
|
+
- Expected vs actual behavior
|
|
204
|
+
- Your environment (OS, Node version, shell)
|
|
45
205
|
|
|
46
206
|
## License
|
|
47
207
|
|
|
48
|
-
This project is licensed under the MIT License.
|
|
208
|
+
This project is licensed under the MIT License. See the LICENSE file for details.
|
|
209
|
+
|
|
210
|
+
## Author
|
|
211
|
+
|
|
212
|
+
**Santhosh Siva**
|
|
213
|
+
- GitHub: [@san-siva](https://github.com/san-siva)
|
|
214
|
+
- Documentation: [gitsy-56895.web.app](https://gitsy-56895.web.app)
|
|
49
215
|
|
|
50
|
-
##
|
|
216
|
+
## Acknowledgments
|
|
51
217
|
|
|
52
|
-
|
|
53
|
-
|
|
218
|
+
Built with:
|
|
219
|
+
- [figlet](http://www.figlet.org/) - ASCII art text generator
|
|
220
|
+
- [lolcat](https://github.com/busyloop/lolcat) - Rainbow colorizer
|
|
221
|
+
- Bash - The GNU Bourne Again Shell
|
package/{g-cb → bin/g-cb}
RENAMED
|
@@ -6,7 +6,15 @@
|
|
|
6
6
|
# Description:
|
|
7
7
|
# This script returns the current branch name in a git repository.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
# Resolve script directory (works with symlinks for npm global install)
|
|
10
|
+
SOURCE="${BASH_SOURCE[0]}"
|
|
11
|
+
while [ -L "$SOURCE" ]; do
|
|
12
|
+
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
|
|
13
|
+
SOURCE="$(readlink "$SOURCE")"
|
|
14
|
+
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
|
|
15
|
+
done
|
|
16
|
+
SCRIPT_DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
|
|
17
|
+
source "$SCRIPT_DIR/utils"
|
|
10
18
|
|
|
11
19
|
set_flags() {
|
|
12
20
|
while [ $# -gt 0 ]; do
|
|
@@ -21,6 +29,7 @@ set_flags() {
|
|
|
21
29
|
exit 0
|
|
22
30
|
;;
|
|
23
31
|
*)
|
|
32
|
+
echo ""
|
|
24
33
|
echo "${RED}Unknown option:${NC} $1"
|
|
25
34
|
exit 1
|
|
26
35
|
;;
|
|
@@ -36,7 +45,8 @@ main() {
|
|
|
36
45
|
print_message "${BLUE}Fetching current branch...${NC}" 1
|
|
37
46
|
current_branch_name=$(git rev-parse --abbrev-ref HEAD)
|
|
38
47
|
if [ -z "$current_branch_name" ]; then
|
|
39
|
-
print_message "
|
|
48
|
+
print_message "" -1
|
|
49
|
+
print_message "${RED}Failed to get current branch.${NC}" -1
|
|
40
50
|
exit 1
|
|
41
51
|
fi
|
|
42
52
|
echo "$current_branch_name" | indent
|
package/{g-co → bin/g-co}
RENAMED
|
@@ -6,7 +6,15 @@
|
|
|
6
6
|
# Description:
|
|
7
7
|
# A script to checkout branches, optionally stash changes, and manage git workflow efficiently.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
# Resolve script directory (works with symlinks for npm global install)
|
|
10
|
+
SOURCE="${BASH_SOURCE[0]}"
|
|
11
|
+
while [ -L "$SOURCE" ]; do
|
|
12
|
+
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
|
|
13
|
+
SOURCE="$(readlink "$SOURCE")"
|
|
14
|
+
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
|
|
15
|
+
done
|
|
16
|
+
SCRIPT_DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
|
|
17
|
+
source "$SCRIPT_DIR/utils"
|
|
10
18
|
|
|
11
19
|
# Default Values
|
|
12
20
|
stash=false
|
|
@@ -29,6 +37,7 @@ set_flags() {
|
|
|
29
37
|
-t=* | --target-branch=*)
|
|
30
38
|
target_branch="${1#*=}"
|
|
31
39
|
if [ -z "$target_branch" ]; then
|
|
40
|
+
echo ""
|
|
32
41
|
echo "${RED}Error: No target branch specified.$NC"
|
|
33
42
|
exit 1
|
|
34
43
|
fi
|
|
@@ -38,6 +47,7 @@ set_flags() {
|
|
|
38
47
|
if [ $# -gt 0 ]; then
|
|
39
48
|
target_branch="$1"
|
|
40
49
|
else
|
|
50
|
+
echo ""
|
|
41
51
|
echo "${RED}Error: No target branch specified.$NC"
|
|
42
52
|
exit 1
|
|
43
53
|
fi
|
|
@@ -87,7 +97,8 @@ checkout_or_create_branch() {
|
|
|
87
97
|
return
|
|
88
98
|
fi
|
|
89
99
|
|
|
90
|
-
print_message "
|
|
100
|
+
print_message "" -1
|
|
101
|
+
print_message "${RED}Aborted.${NC}" -1
|
|
91
102
|
exit 1
|
|
92
103
|
}
|
|
93
104
|
|
package/{g-db → bin/g-db}
RENAMED
|
@@ -6,7 +6,15 @@
|
|
|
6
6
|
# Description:
|
|
7
7
|
# A script to delete a branch locally and push the deletion to remote.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
# Resolve script directory (works with symlinks for npm global install)
|
|
10
|
+
SOURCE="${BASH_SOURCE[0]}"
|
|
11
|
+
while [ -L "$SOURCE" ]; do
|
|
12
|
+
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
|
|
13
|
+
SOURCE="$(readlink "$SOURCE")"
|
|
14
|
+
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
|
|
15
|
+
done
|
|
16
|
+
SCRIPT_DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
|
|
17
|
+
source "$SCRIPT_DIR/utils"
|
|
10
18
|
|
|
11
19
|
# Default Values
|
|
12
20
|
target_branch=
|
|
@@ -27,6 +35,7 @@ set_flags() {
|
|
|
27
35
|
-t=* | --target-branch=*)
|
|
28
36
|
target_branch="${1#*=}"
|
|
29
37
|
if [ -z "$target_branch" ]; then
|
|
38
|
+
echo ""
|
|
30
39
|
echo "${RED}Error: No target branch specified.$NC"
|
|
31
40
|
exit 1
|
|
32
41
|
fi
|
|
@@ -36,11 +45,13 @@ set_flags() {
|
|
|
36
45
|
if [ $# -gt 0 ]; then
|
|
37
46
|
target_branch="$1"
|
|
38
47
|
else
|
|
48
|
+
echo ""
|
|
39
49
|
echo "${RED}Error: No target branch specified.$NC"
|
|
40
50
|
exit 1
|
|
41
51
|
fi
|
|
42
52
|
;;
|
|
43
53
|
*)
|
|
54
|
+
echo ""
|
|
44
55
|
echo "${RED}Unknown option:${NC} $1"
|
|
45
56
|
exit 1
|
|
46
57
|
;;
|
|
@@ -59,18 +70,20 @@ delete_local_branch() {
|
|
|
59
70
|
return 0
|
|
60
71
|
fi
|
|
61
72
|
|
|
62
|
-
current_branch=$(
|
|
73
|
+
current_branch=$(get_current_branch)
|
|
63
74
|
if [ "${branch}" = "${current_branch}" ]; then
|
|
64
|
-
print_message "
|
|
65
|
-
print_message "${RED}
|
|
75
|
+
print_message "" -1
|
|
76
|
+
print_message "${RED}Cannot delete the branch you are currently on.${NC}" -1
|
|
77
|
+
print_message "${RED}Please checkout to another branch first.${NC}" -1
|
|
66
78
|
exit 1
|
|
67
79
|
fi
|
|
68
80
|
|
|
69
81
|
print_message "${BLUE}Deleting local branch ${NC}${branch}${BLUE}...${NC}" $step_number
|
|
70
82
|
|
|
71
83
|
if ! git -c color.ui=always branch -d "${branch}" 2>&1 | indent; then
|
|
72
|
-
print_message "
|
|
73
|
-
print_message "${
|
|
84
|
+
print_message "" -1
|
|
85
|
+
print_message "${RED}Failed to delete local branch ${NC}${branch}${RED}. [Fail]${NC}" -1
|
|
86
|
+
print_message "${PROMPT}Hint: Branch may not be fully merged. Use 'git branch -D ${branch}' to force delete.${NC}" -1
|
|
74
87
|
exit 1
|
|
75
88
|
fi
|
|
76
89
|
|
|
@@ -92,7 +105,8 @@ prompt_remote_deletion() {
|
|
|
92
105
|
|
|
93
106
|
print_message "${BLUE}Deleting remote branch ${NC}origin/${branch}${BLUE}...${NC}" 6
|
|
94
107
|
if ! git -c color.ui=always push origin --delete "${branch}" 2>&1 | indent; then
|
|
95
|
-
print_message "
|
|
108
|
+
print_message "" -1
|
|
109
|
+
print_message "${RED}Failed to delete remote branch ${NC}origin/${branch}${RED}. [Fail]${NC}" -1
|
|
96
110
|
exit 1
|
|
97
111
|
fi
|
|
98
112
|
|
package/{g-diff → bin/g-diff}
RENAMED
|
@@ -6,7 +6,15 @@
|
|
|
6
6
|
# Description:
|
|
7
7
|
# A script to compare changes between two git branches.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
# Resolve script directory (works with symlinks for npm global install)
|
|
10
|
+
SOURCE="${BASH_SOURCE[0]}"
|
|
11
|
+
while [ -L "$SOURCE" ]; do
|
|
12
|
+
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
|
|
13
|
+
SOURCE="$(readlink "$SOURCE")"
|
|
14
|
+
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
|
|
15
|
+
done
|
|
16
|
+
SCRIPT_DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
|
|
17
|
+
source "$SCRIPT_DIR/utils"
|
|
10
18
|
|
|
11
19
|
target_branch=""
|
|
12
20
|
source_branch=""
|
|
@@ -38,7 +46,8 @@ set_flags() {
|
|
|
38
46
|
-t=* | --target-branch=*)
|
|
39
47
|
target_branch="${1#*=}"
|
|
40
48
|
if [ -z "$target_branch" ]; then
|
|
41
|
-
print_message "
|
|
49
|
+
print_message "" -1
|
|
50
|
+
print_message "${RED}Error: No target branch specified.${NC}" -1
|
|
42
51
|
exit 1
|
|
43
52
|
fi
|
|
44
53
|
;;
|
|
@@ -47,14 +56,16 @@ set_flags() {
|
|
|
47
56
|
if [ $# -gt 0 ]; then
|
|
48
57
|
target_branch="$1"
|
|
49
58
|
else
|
|
50
|
-
print_message "
|
|
59
|
+
print_message "" -1
|
|
60
|
+
print_message "${RED}Error: No target branch specified.${NC}" -1
|
|
51
61
|
exit 1
|
|
52
62
|
fi
|
|
53
63
|
;;
|
|
54
64
|
-s=* | --source-branch=*)
|
|
55
65
|
source_branch="${1#*=}"
|
|
56
66
|
if [ -z "$source_branch" ]; then
|
|
57
|
-
print_message "
|
|
67
|
+
print_message "" -1
|
|
68
|
+
print_message "${RED}Error: No source branch specified.${NC}" -1
|
|
58
69
|
exit 1
|
|
59
70
|
fi
|
|
60
71
|
;;
|
|
@@ -63,12 +74,14 @@ set_flags() {
|
|
|
63
74
|
if [ $# -gt 0 ]; then
|
|
64
75
|
source_branch="$1"
|
|
65
76
|
else
|
|
66
|
-
print_message "
|
|
77
|
+
print_message "" -1
|
|
78
|
+
print_message "${RED}Error: No source branch specified.${NC}" -1
|
|
67
79
|
exit 1
|
|
68
80
|
fi
|
|
69
81
|
;;
|
|
70
82
|
*)
|
|
71
|
-
print_message "
|
|
83
|
+
print_message "" -1
|
|
84
|
+
print_message "${RED}Unknown option:${NC} $1" -1
|
|
72
85
|
exit 1
|
|
73
86
|
;;
|
|
74
87
|
esac
|
|
@@ -151,7 +164,8 @@ show_files_only() {
|
|
|
151
164
|
local filenames
|
|
152
165
|
if ! filenames=$(git diff --name-only "${source_branch}..origin/${target_branch}" 2>&1); then
|
|
153
166
|
echo "$filenames" | indent
|
|
154
|
-
print_message "
|
|
167
|
+
print_message "" -1
|
|
168
|
+
print_message "${RED}Failed to compare branches.${NC}" -1
|
|
155
169
|
exit 1
|
|
156
170
|
fi
|
|
157
171
|
|
|
@@ -166,7 +180,8 @@ show_stat_summary() {
|
|
|
166
180
|
local result
|
|
167
181
|
if ! result=$(git -c color.ui=always diff --stat "${source_branch}..origin/${target_branch}" 2>&1); then
|
|
168
182
|
echo "$result" | indent
|
|
169
|
-
print_message "
|
|
183
|
+
print_message "" -1
|
|
184
|
+
print_message "${RED}Failed to compare branches.${NC}" -1
|
|
170
185
|
exit 1
|
|
171
186
|
fi
|
|
172
187
|
|
|
@@ -186,9 +201,10 @@ compare_branches() {
|
|
|
186
201
|
|
|
187
202
|
if [ -z "$source_branch" ]; then
|
|
188
203
|
print_message "${BLUE}Source branch not specified, using current branch...${NC}" $step_number
|
|
189
|
-
source_branch=$(
|
|
204
|
+
source_branch=$(get_current_branch true)
|
|
190
205
|
if [ -z "$source_branch" ]; then
|
|
191
|
-
print_message "
|
|
206
|
+
print_message "" -1
|
|
207
|
+
print_message "${RED}Failed to get current branch.${NC}" -1
|
|
192
208
|
exit 1
|
|
193
209
|
fi
|
|
194
210
|
step_number=$((step_number + 1))
|
|
@@ -196,7 +212,8 @@ compare_branches() {
|
|
|
196
212
|
|
|
197
213
|
print_message "${BLUE}Fetching latest changes for target branch ${NC}${target_branch}${BLUE}...${NC}" $step_number
|
|
198
214
|
if ! fetch_changes "${target_branch}"; then
|
|
199
|
-
print_message "
|
|
215
|
+
print_message "" -1
|
|
216
|
+
print_message "${RED}Failed to fetch target branch ${NC}${target_branch}${RED}.${NC}" -1
|
|
200
217
|
exit 1
|
|
201
218
|
fi
|
|
202
219
|
|
package/{g-dlc → bin/g-dlc}
RENAMED
|
@@ -6,7 +6,15 @@
|
|
|
6
6
|
# Description:
|
|
7
7
|
# A script to discard the last commit with optional force mode.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
# Resolve script directory (works with symlinks for npm global install)
|
|
10
|
+
SOURCE="${BASH_SOURCE[0]}"
|
|
11
|
+
while [ -L "$SOURCE" ]; do
|
|
12
|
+
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
|
|
13
|
+
SOURCE="$(readlink "$SOURCE")"
|
|
14
|
+
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
|
|
15
|
+
done
|
|
16
|
+
SCRIPT_DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
|
|
17
|
+
source "$SCRIPT_DIR/utils"
|
|
10
18
|
|
|
11
19
|
# Default Values
|
|
12
20
|
force_mode=false
|
|
@@ -40,6 +48,7 @@ set_flags() {
|
|
|
40
48
|
fi
|
|
41
49
|
;;
|
|
42
50
|
*)
|
|
51
|
+
echo ""
|
|
43
52
|
echo "${RED}Unknown option:${NC} $1"
|
|
44
53
|
exit 1
|
|
45
54
|
;;
|
|
@@ -66,8 +75,9 @@ verify_no_uncommitted_changes() {
|
|
|
66
75
|
if [ "$force_mode" = "false" ]; then
|
|
67
76
|
print_message "${BLUE}Checking for uncommitted changes...${NC}" 2
|
|
68
77
|
if has_uncommitted_changes "."; then
|
|
69
|
-
print_message "
|
|
70
|
-
print_message "${RED}
|
|
78
|
+
print_message "" -1
|
|
79
|
+
print_message "${RED}Error: There are uncommitted changes in your working directory.${NC}" -1
|
|
80
|
+
print_message "${RED}Please commit or stash your changes before discarding the last commit.${NC}" -1
|
|
71
81
|
exit 1
|
|
72
82
|
fi
|
|
73
83
|
print_message "${GREEN}No uncommitted changes found.${NC}" 0
|
|
@@ -88,7 +98,8 @@ discard_last_commit() {
|
|
|
88
98
|
echo "$reset_output" | indent
|
|
89
99
|
fi
|
|
90
100
|
if [ $reset_exit_code -ne 0 ]; then
|
|
91
|
-
print_message "
|
|
101
|
+
print_message "" -1
|
|
102
|
+
print_message "${RED}Failed to discard the last commit. [Fail]${NC}" -1
|
|
92
103
|
exit 1
|
|
93
104
|
fi
|
|
94
105
|
|
package/{g-pull → bin/g-pull}
RENAMED
|
@@ -6,9 +6,15 @@
|
|
|
6
6
|
# Description:
|
|
7
7
|
# A script to checkout branches, optionally stash changes, and manage git workflow efficiently.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
# Resolve script directory (works with symlinks for npm global install)
|
|
10
|
+
SOURCE="${BASH_SOURCE[0]}"
|
|
11
|
+
while [ -L "$SOURCE" ]; do
|
|
12
|
+
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
|
|
13
|
+
SOURCE="$(readlink "$SOURCE")"
|
|
14
|
+
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
|
|
15
|
+
done
|
|
16
|
+
SCRIPT_DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
|
|
17
|
+
source "$SCRIPT_DIR/utils"
|
|
12
18
|
|
|
13
19
|
target_branch=
|
|
14
20
|
do_fetch=false
|
|
@@ -57,7 +63,7 @@ main() {
|
|
|
57
63
|
validate_dependencies
|
|
58
64
|
print_banner
|
|
59
65
|
if [ -z "$target_branch" ]; then
|
|
60
|
-
target_branch=$(
|
|
66
|
+
target_branch=$(get_current_branch)
|
|
61
67
|
fi
|
|
62
68
|
if [ "$do_fetch" = "true" ]; then
|
|
63
69
|
print_message "${BLUE}Fetching changes...${NC}" 1
|
package/{g-push → bin/g-push}
RENAMED
|
@@ -6,9 +6,15 @@
|
|
|
6
6
|
# Description:
|
|
7
7
|
# A script to checkout branches, optionally stash changes, and manage git workflow efficiently.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
# Resolve script directory (works with symlinks for npm global install)
|
|
10
|
+
SOURCE="${BASH_SOURCE[0]}"
|
|
11
|
+
while [ -L "$SOURCE" ]; do
|
|
12
|
+
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
|
|
13
|
+
SOURCE="$(readlink "$SOURCE")"
|
|
14
|
+
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
|
|
15
|
+
done
|
|
16
|
+
SCRIPT_DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
|
|
17
|
+
source "$SCRIPT_DIR/utils"
|
|
12
18
|
|
|
13
19
|
target_branch=
|
|
14
20
|
should_force_push=false
|
|
@@ -31,6 +37,7 @@ set_flags() {
|
|
|
31
37
|
-t=* | --target-branch=*)
|
|
32
38
|
target_branch="${1#*=}"
|
|
33
39
|
if [ -z "$target_branch" ]; then
|
|
40
|
+
echo ""
|
|
34
41
|
echo "${RED}Error: No target branch specified.$NC"
|
|
35
42
|
exit 1
|
|
36
43
|
fi
|
|
@@ -40,6 +47,7 @@ set_flags() {
|
|
|
40
47
|
if [ $# -gt 0 ]; then
|
|
41
48
|
target_branch="$1"
|
|
42
49
|
else
|
|
50
|
+
echo ""
|
|
43
51
|
echo "${RED}Error: No target branch specified.$NC"
|
|
44
52
|
exit 1
|
|
45
53
|
fi
|
|
@@ -57,7 +65,7 @@ main() {
|
|
|
57
65
|
validate_dependencies
|
|
58
66
|
print_banner
|
|
59
67
|
if [ -z "$target_branch" ]; then
|
|
60
|
-
push_changes $(
|
|
68
|
+
push_changes $(get_current_branch) $should_force_push 1
|
|
61
69
|
exit 0
|
|
62
70
|
fi
|
|
63
71
|
push_changes "$target_branch" $should_force_push 1
|
package/{g-rmf → bin/g-rmf}
RENAMED
|
@@ -7,7 +7,15 @@
|
|
|
7
7
|
# A script to clear your working directory by stashing changes.
|
|
8
8
|
# The stashed changes is tagged with the current date and time.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
# Resolve script directory (works with symlinks for npm global install)
|
|
11
|
+
SOURCE="${BASH_SOURCE[0]}"
|
|
12
|
+
while [ -L "$SOURCE" ]; do
|
|
13
|
+
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
|
|
14
|
+
SOURCE="$(readlink "$SOURCE")"
|
|
15
|
+
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
|
|
16
|
+
done
|
|
17
|
+
SCRIPT_DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
|
|
18
|
+
source "$SCRIPT_DIR/utils"
|
|
11
19
|
|
|
12
20
|
# Default Values
|
|
13
21
|
tag_message=
|
|
@@ -33,6 +41,7 @@ set_flags() {
|
|
|
33
41
|
if [ $# -gt 0 ]; then
|
|
34
42
|
tag_message="$1"
|
|
35
43
|
else
|
|
44
|
+
echo ""
|
|
36
45
|
echo "${RED}Error: No message specified.$NC"
|
|
37
46
|
exit 1
|
|
38
47
|
fi
|
package/{g-rto → bin/g-rto}
RENAMED
|
@@ -7,7 +7,15 @@
|
|
|
7
7
|
# A script to quickly reset your working directory to the latest changes from the remote branch.
|
|
8
8
|
# In case you ran this command by mistake, you can use the `git stash apply` command to restore your changes.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
# Resolve script directory (works with symlinks for npm global install)
|
|
11
|
+
SOURCE="${BASH_SOURCE[0]}"
|
|
12
|
+
while [ -L "$SOURCE" ]; do
|
|
13
|
+
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
|
|
14
|
+
SOURCE="$(readlink "$SOURCE")"
|
|
15
|
+
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
|
|
16
|
+
done
|
|
17
|
+
SCRIPT_DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
|
|
18
|
+
source "$SCRIPT_DIR/utils"
|
|
11
19
|
|
|
12
20
|
set_flags() {
|
|
13
21
|
while [ $# -gt 0 ]; do
|
|
@@ -22,6 +30,7 @@ set_flags() {
|
|
|
22
30
|
exit 0
|
|
23
31
|
;;
|
|
24
32
|
*)
|
|
33
|
+
echo ""
|
|
25
34
|
echo "${RED}Unknown option:${NC} $1"
|
|
26
35
|
exit 1
|
|
27
36
|
;;
|
|
@@ -34,7 +43,7 @@ main() {
|
|
|
34
43
|
set_flags "$@"
|
|
35
44
|
validate_dependencies git figlet lolcat
|
|
36
45
|
print_banner
|
|
37
|
-
target_branch=$(
|
|
46
|
+
target_branch=$(get_current_branch)
|
|
38
47
|
stash_changes true 1
|
|
39
48
|
print_message ""
|
|
40
49
|
|