@san-siva/gitsy 1.0.1 → 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 CHANGED
@@ -1,5 +1,6 @@
1
1
  # gitsy
2
2
 
3
+ ![gitsy in action](images/demo.png)
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
 
5
6
  ## Documentation
@@ -22,7 +23,7 @@ For complete documentation, usage examples, and detailed command reference, visi
22
23
  | `g-co` | Checkout branch with optional stashing |
23
24
  | `g-pull` | Pull changes from remote branch |
24
25
  | `g-push` | Push changes to remote (supports force push) |
25
- | `g-wa` | Create git worktree for a branch |
26
+ | `g-wa` | Create git worktree with automatic repository restructuring |
26
27
  | `g-wr` | Remove git worktree |
27
28
  | `g-db` | Delete branch locally and remotely |
28
29
  | `g-dlc` | Discard last commit |
@@ -99,6 +100,34 @@ g-co -t feature-branch
99
100
  g-wa -t new-feature
100
101
  ```
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
+
102
131
  **Pull latest changes:**
103
132
  ```bash
104
133
  g-pull
@@ -122,8 +151,9 @@ For complete command documentation and advanced usage examples, visit the [gitsy
122
151
  - **Color-coded output** - Easy-to-read, colorful terminal output powered by lolcat
123
152
  - **Safety checks** - Built-in validations prevent common git mistakes
124
153
  - **Automation** - Streamlines complex git workflows into single commands
125
- - **Worktree management** - Simplified git worktree creation and removal
154
+ - **Intelligent worktree management** - Automatic repository restructuring for seamless worktree workflows
126
155
  - **Branch operations** - Quick branch switching, creation, and deletion
156
+ - **Step-by-step feedback** - Clear progress indicators show exactly what's happening
127
157
 
128
158
  ## Contributing
129
159
 
@@ -29,6 +29,7 @@ set_flags() {
29
29
  exit 0
30
30
  ;;
31
31
  *)
32
+ echo ""
32
33
  echo "${RED}Unknown option:${NC} $1"
33
34
  exit 1
34
35
  ;;
@@ -44,7 +45,8 @@ main() {
44
45
  print_message "${BLUE}Fetching current branch...${NC}" 1
45
46
  current_branch_name=$(git rev-parse --abbrev-ref HEAD)
46
47
  if [ -z "$current_branch_name" ]; then
47
- print_message "${RED}Failed to get current branch.${NC}"
48
+ print_message "" -1
49
+ print_message "${RED}Failed to get current branch.${NC}" -1
48
50
  exit 1
49
51
  fi
50
52
  echo "$current_branch_name" | indent
@@ -37,6 +37,7 @@ set_flags() {
37
37
  -t=* | --target-branch=*)
38
38
  target_branch="${1#*=}"
39
39
  if [ -z "$target_branch" ]; then
40
+ echo ""
40
41
  echo "${RED}Error: No target branch specified.$NC"
41
42
  exit 1
42
43
  fi
@@ -46,6 +47,7 @@ set_flags() {
46
47
  if [ $# -gt 0 ]; then
47
48
  target_branch="$1"
48
49
  else
50
+ echo ""
49
51
  echo "${RED}Error: No target branch specified.$NC"
50
52
  exit 1
51
53
  fi
@@ -95,7 +97,8 @@ checkout_or_create_branch() {
95
97
  return
96
98
  fi
97
99
 
98
- print_message "${RED}Aborted.${NC}"
100
+ print_message "" -1
101
+ print_message "${RED}Aborted.${NC}" -1
99
102
  exit 1
100
103
  }
101
104
 
@@ -35,6 +35,7 @@ set_flags() {
35
35
  -t=* | --target-branch=*)
36
36
  target_branch="${1#*=}"
37
37
  if [ -z "$target_branch" ]; then
38
+ echo ""
38
39
  echo "${RED}Error: No target branch specified.$NC"
39
40
  exit 1
40
41
  fi
@@ -44,11 +45,13 @@ set_flags() {
44
45
  if [ $# -gt 0 ]; then
45
46
  target_branch="$1"
46
47
  else
48
+ echo ""
47
49
  echo "${RED}Error: No target branch specified.$NC"
48
50
  exit 1
49
51
  fi
50
52
  ;;
51
53
  *)
54
+ echo ""
52
55
  echo "${RED}Unknown option:${NC} $1"
53
56
  exit 1
54
57
  ;;
@@ -67,18 +70,20 @@ delete_local_branch() {
67
70
  return 0
68
71
  fi
69
72
 
70
- current_branch=$(fetch_current_branch)
73
+ current_branch=$(get_current_branch)
71
74
  if [ "${branch}" = "${current_branch}" ]; then
72
- print_message "${RED}Cannot delete the branch you are currently on.${NC}"
73
- print_message "${RED}Please checkout to another branch first.${NC}"
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
74
78
  exit 1
75
79
  fi
76
80
 
77
81
  print_message "${BLUE}Deleting local branch ${NC}${branch}${BLUE}...${NC}" $step_number
78
82
 
79
83
  if ! git -c color.ui=always branch -d "${branch}" 2>&1 | indent; then
80
- print_message "${RED}Failed to delete local branch ${NC}${branch}${RED}. [Fail]${NC}"
81
- print_message "${PROMPT}Hint: Branch may not be fully merged. Use 'git branch -D ${branch}' to force delete.${NC}"
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
82
87
  exit 1
83
88
  fi
84
89
 
@@ -100,7 +105,8 @@ prompt_remote_deletion() {
100
105
 
101
106
  print_message "${BLUE}Deleting remote branch ${NC}origin/${branch}${BLUE}...${NC}" 6
102
107
  if ! git -c color.ui=always push origin --delete "${branch}" 2>&1 | indent; then
103
- print_message "${RED}Failed to delete remote branch ${NC}origin/${branch}${RED}. [Fail]${NC}"
108
+ print_message "" -1
109
+ print_message "${RED}Failed to delete remote branch ${NC}origin/${branch}${RED}. [Fail]${NC}" -1
104
110
  exit 1
105
111
  fi
106
112
 
@@ -46,7 +46,8 @@ set_flags() {
46
46
  -t=* | --target-branch=*)
47
47
  target_branch="${1#*=}"
48
48
  if [ -z "$target_branch" ]; then
49
- print_message "${RED}Error: No target branch specified.${NC}"
49
+ print_message "" -1
50
+ print_message "${RED}Error: No target branch specified.${NC}" -1
50
51
  exit 1
51
52
  fi
52
53
  ;;
@@ -55,14 +56,16 @@ set_flags() {
55
56
  if [ $# -gt 0 ]; then
56
57
  target_branch="$1"
57
58
  else
58
- print_message "${RED}Error: No target branch specified.${NC}"
59
+ print_message "" -1
60
+ print_message "${RED}Error: No target branch specified.${NC}" -1
59
61
  exit 1
60
62
  fi
61
63
  ;;
62
64
  -s=* | --source-branch=*)
63
65
  source_branch="${1#*=}"
64
66
  if [ -z "$source_branch" ]; then
65
- print_message "${RED}Error: No source branch specified.${NC}"
67
+ print_message "" -1
68
+ print_message "${RED}Error: No source branch specified.${NC}" -1
66
69
  exit 1
67
70
  fi
68
71
  ;;
@@ -71,12 +74,14 @@ set_flags() {
71
74
  if [ $# -gt 0 ]; then
72
75
  source_branch="$1"
73
76
  else
74
- print_message "${RED}Error: No source branch specified.${NC}"
77
+ print_message "" -1
78
+ print_message "${RED}Error: No source branch specified.${NC}" -1
75
79
  exit 1
76
80
  fi
77
81
  ;;
78
82
  *)
79
- print_message "${RED}Unknown option:${NC} $1"
83
+ print_message "" -1
84
+ print_message "${RED}Unknown option:${NC} $1" -1
80
85
  exit 1
81
86
  ;;
82
87
  esac
@@ -159,7 +164,8 @@ show_files_only() {
159
164
  local filenames
160
165
  if ! filenames=$(git diff --name-only "${source_branch}..origin/${target_branch}" 2>&1); then
161
166
  echo "$filenames" | indent
162
- print_message "${RED}Failed to compare branches.${NC}"
167
+ print_message "" -1
168
+ print_message "${RED}Failed to compare branches.${NC}" -1
163
169
  exit 1
164
170
  fi
165
171
 
@@ -174,7 +180,8 @@ show_stat_summary() {
174
180
  local result
175
181
  if ! result=$(git -c color.ui=always diff --stat "${source_branch}..origin/${target_branch}" 2>&1); then
176
182
  echo "$result" | indent
177
- print_message "${RED}Failed to compare branches.${NC}"
183
+ print_message "" -1
184
+ print_message "${RED}Failed to compare branches.${NC}" -1
178
185
  exit 1
179
186
  fi
180
187
 
@@ -194,9 +201,10 @@ compare_branches() {
194
201
 
195
202
  if [ -z "$source_branch" ]; then
196
203
  print_message "${BLUE}Source branch not specified, using current branch...${NC}" $step_number
197
- source_branch=$(fetch_current_branch true)
204
+ source_branch=$(get_current_branch true)
198
205
  if [ -z "$source_branch" ]; then
199
- print_message "${RED}Failed to get current branch.${NC}"
206
+ print_message "" -1
207
+ print_message "${RED}Failed to get current branch.${NC}" -1
200
208
  exit 1
201
209
  fi
202
210
  step_number=$((step_number + 1))
@@ -204,7 +212,8 @@ compare_branches() {
204
212
 
205
213
  print_message "${BLUE}Fetching latest changes for target branch ${NC}${target_branch}${BLUE}...${NC}" $step_number
206
214
  if ! fetch_changes "${target_branch}"; then
207
- print_message "${RED}Failed to fetch target branch ${NC}${target_branch}${RED}.${NC}"
215
+ print_message "" -1
216
+ print_message "${RED}Failed to fetch target branch ${NC}${target_branch}${RED}.${NC}" -1
208
217
  exit 1
209
218
  fi
210
219
 
@@ -48,6 +48,7 @@ set_flags() {
48
48
  fi
49
49
  ;;
50
50
  *)
51
+ echo ""
51
52
  echo "${RED}Unknown option:${NC} $1"
52
53
  exit 1
53
54
  ;;
@@ -74,8 +75,9 @@ verify_no_uncommitted_changes() {
74
75
  if [ "$force_mode" = "false" ]; then
75
76
  print_message "${BLUE}Checking for uncommitted changes...${NC}" 2
76
77
  if has_uncommitted_changes "."; then
77
- print_message "${RED}Error: There are uncommitted changes in your working directory.${NC}" 0
78
- print_message "${RED}Please commit or stash your changes before discarding the last commit.${NC}" 0
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
79
81
  exit 1
80
82
  fi
81
83
  print_message "${GREEN}No uncommitted changes found.${NC}" 0
@@ -96,7 +98,8 @@ discard_last_commit() {
96
98
  echo "$reset_output" | indent
97
99
  fi
98
100
  if [ $reset_exit_code -ne 0 ]; then
99
- print_message "${RED}Failed to discard the last commit. [Fail]${NC}" 0
101
+ print_message "" -1
102
+ print_message "${RED}Failed to discard the last commit. [Fail]${NC}" -1
100
103
  exit 1
101
104
  fi
102
105
 
@@ -63,7 +63,7 @@ main() {
63
63
  validate_dependencies
64
64
  print_banner
65
65
  if [ -z "$target_branch" ]; then
66
- target_branch=$(fetch_current_branch)
66
+ target_branch=$(get_current_branch)
67
67
  fi
68
68
  if [ "$do_fetch" = "true" ]; then
69
69
  print_message "${BLUE}Fetching changes...${NC}" 1
@@ -37,6 +37,7 @@ set_flags() {
37
37
  -t=* | --target-branch=*)
38
38
  target_branch="${1#*=}"
39
39
  if [ -z "$target_branch" ]; then
40
+ echo ""
40
41
  echo "${RED}Error: No target branch specified.$NC"
41
42
  exit 1
42
43
  fi
@@ -46,6 +47,7 @@ set_flags() {
46
47
  if [ $# -gt 0 ]; then
47
48
  target_branch="$1"
48
49
  else
50
+ echo ""
49
51
  echo "${RED}Error: No target branch specified.$NC"
50
52
  exit 1
51
53
  fi
@@ -63,7 +65,7 @@ main() {
63
65
  validate_dependencies
64
66
  print_banner
65
67
  if [ -z "$target_branch" ]; then
66
- push_changes $(fetch_current_branch) $should_force_push 1
68
+ push_changes $(get_current_branch) $should_force_push 1
67
69
  exit 0
68
70
  fi
69
71
  push_changes "$target_branch" $should_force_push 1
@@ -41,6 +41,7 @@ set_flags() {
41
41
  if [ $# -gt 0 ]; then
42
42
  tag_message="$1"
43
43
  else
44
+ echo ""
44
45
  echo "${RED}Error: No message specified.$NC"
45
46
  exit 1
46
47
  fi
@@ -30,6 +30,7 @@ set_flags() {
30
30
  exit 0
31
31
  ;;
32
32
  *)
33
+ echo ""
33
34
  echo "${RED}Unknown option:${NC} $1"
34
35
  exit 1
35
36
  ;;
@@ -42,7 +43,7 @@ main() {
42
43
  set_flags "$@"
43
44
  validate_dependencies git figlet lolcat
44
45
  print_banner
45
- target_branch=$(fetch_current_branch)
46
+ target_branch=$(get_current_branch)
46
47
  stash_changes true 1
47
48
  print_message ""
48
49
 
package/{g-s → bin/g-s} RENAMED
@@ -29,6 +29,7 @@ set_flags() {
29
29
  exit 0
30
30
  ;;
31
31
  *)
32
+ echo ""
32
33
  echo "${RED}Unknown option:${NC} $1"
33
34
  exit 1
34
35
  ;;
@@ -43,7 +44,7 @@ main() {
43
44
  print_banner
44
45
  print_message "${BLUE}Fetching git status...${NC}" 1
45
46
 
46
- current_branch=$(fetch_current_branch)
47
+ current_branch=$(get_current_branch)
47
48
 
48
49
  if ! git -c color.ui=always status 2>&1 | indent; then
49
50
  print_message "${PROMPT}Failed to get git status. Are you in a git repository?${NC}"