gitbash 1.3.2 → 1.3.4

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.
@@ -2,6 +2,13 @@
2
2
  # shellcheck disable=SC2155
3
3
  # Common utilities for gitbash commands - compatible with bash and zsh
4
4
 
5
+ # Load config file if it exists
6
+ CONFIG_FILE="$HOME/.gitbashrc"
7
+ if [[ -f "$CONFIG_FILE" ]]; then
8
+ # shellcheck disable=SC1090
9
+ source "$CONFIG_FILE"
10
+ fi
11
+
5
12
  # Color codes for consistent output
6
13
  COLOR_RED='\033[0;31m'
7
14
  COLOR_GREEN='\033[0;32m'
@@ -126,9 +126,9 @@ EOF
126
126
  # 4. Extract stash IDs safely
127
127
  # -----------------------------
128
128
  local stash_ids=()
129
+ local stash_id line
129
130
  while IFS= read -r line; do
130
- local stash_id
131
- stash_id=$(echo "$line" | grep -o 'stash@{[0-9]\+}')
131
+ stash_id=$(echo "$line" | grep -o 'stash@{[0-9]\+}' || true)
132
132
  if [[ -n "$stash_id" ]]; then
133
133
  stash_ids+=("$stash_id")
134
134
  fi
@@ -157,6 +157,7 @@ EOF
157
157
  echo "Deleting stashes..."
158
158
  # Sort by stash number in descending order to delete safely
159
159
  local sorted_ids=()
160
+ local id
160
161
  while IFS= read -r id; do
161
162
  sorted_ids+=("$id")
162
163
  done < <(printf '%s\n' "${stash_ids[@]}" | sort -t'{' -k2 -rn)
@@ -163,6 +163,10 @@ EOF
163
163
  stale_branches=()
164
164
  recent_branches=()
165
165
 
166
+ # Variables for loop (declared once to avoid zsh output on redeclaration)
167
+ local last_commit_ts relative_date author_email author_name
168
+ local has_remote configured_upstream entry
169
+
166
170
  # Process each local branch
167
171
  while IFS= read -r branch; do
168
172
  # Skip base branch
@@ -170,24 +174,22 @@ EOF
170
174
  [[ -z "$branch" ]] && continue
171
175
 
172
176
  # Get last commit info for all branches
173
- local last_commit_ts relative_date author_email author_name
174
177
  last_commit_ts=$(git log -1 --format='%ct' "$branch" 2>/dev/null)
175
178
  relative_date=$(git log -1 --format='%cr' "$branch" 2>/dev/null)
176
179
  author_email=$(git log -1 --format='%ae' "$branch" 2>/dev/null)
177
180
  author_name=$(git log -1 --format='%an' "$branch" 2>/dev/null)
178
181
 
179
182
  # Check if remote branch exists
180
- local has_remote=false
183
+ has_remote=false
181
184
  if echo "$remote_branches" | grep -qx "$branch"; then
182
185
  has_remote=true
183
186
  fi
184
187
 
185
188
  # Check if it HAD an upstream (was pushed before)
186
- local configured_upstream
187
189
  configured_upstream=$(git config "branch.$branch.remote" 2>/dev/null)
188
190
 
189
191
  # Entry format: timestamp|branch|relative_date|author_email|author_name
190
- local entry="$last_commit_ts|$branch|$relative_date|$author_email|$author_name"
192
+ entry="$last_commit_ts|$branch|$relative_date|$author_email|$author_name"
191
193
 
192
194
  if [[ "$has_remote" == false && -n "$configured_upstream" ]]; then
193
195
  # Had upstream but remote is gone = merged and deleted remotely
@@ -205,9 +207,9 @@ EOF
205
207
  _sort_desc() {
206
208
  local _var="$1"
207
209
  shift
208
- local _out=()
209
- while IFS= read -r line; do
210
- _out+=("$line")
210
+ local _out=() _line
211
+ while IFS= read -r _line; do
212
+ _out+=("$_line")
211
213
  done < <(printf '%s\n' "$@" | sort -t'|' -k1 -rn)
212
214
  # shellcheck disable=SC2034 # assigned via eval to caller var
213
215
  eval "$_var=(\"\${_out[@]}\")"
@@ -427,10 +429,10 @@ Found $total_count branches ($preselect_count pre-selected for deletion)" \
427
429
  local branches_to_delete=()
428
430
  local need_switch=false
429
431
  local only_merged=true
432
+ local branch_name line
430
433
 
431
434
  while IFS= read -r line; do
432
435
  [[ "$line" == "✖ Abort"* ]] && continue
433
- local branch_name
434
436
  branch_name=$(echo "$line" | cut -f2)
435
437
  if [[ -n "$branch_name" ]]; then
436
438
  branches_to_delete+=("$branch_name")
@@ -196,13 +196,13 @@ TYPES
196
196
  print_info "No Jira link provided. Using NOISSUE."
197
197
  else
198
198
  # First try to match just the issue number pattern (e.g., PROJ-123)
199
- issue_number=$(echo "$jira_link" | grep -o -E '^[A-Z]+-[0-9]+$' | head -1)
199
+ issue_number=$(echo "$jira_link" | grep -o -E '^[A-Z]+-[0-9]+$' | head -1 || true)
200
200
 
201
201
  # If not a direct match, try to extract from URL
202
202
  if [[ -z "$issue_number" ]]; then
203
203
  # Match patterns like PROJ-123, ABC-456, etc.
204
204
  # Supports both /browse/PROJ-123 and selectedIssue=PROJ-123 formats
205
- issue_number=$(echo "$jira_link" | grep -o -E '(browse/|selectedIssue=)[A-Z]+-[0-9]+' | grep -o '[A-Z]\+-[0-9]\+' | head -1)
205
+ issue_number=$(echo "$jira_link" | grep -o -E '(browse/|selectedIssue=)[A-Z]+-[0-9]+' | grep -o '[A-Z]\+-[0-9]\+' | head -1 || true)
206
206
  fi
207
207
 
208
208
  if [[ -z "$issue_number" ]]; then
@@ -218,7 +218,6 @@ TYPES
218
218
  echo "Parsed issue number: $issue_number"
219
219
  fi
220
220
  fi
221
- echo
222
221
 
223
222
  # -----------------------------
224
223
  # 3. Get branch title from user (if not already provided)
@@ -242,9 +241,7 @@ TYPES
242
241
  # branch_prefix is set earlier from type menu, flag, or config
243
242
  local branch_name="${branch_prefix}${issue_number}-${branch_title}"
244
243
 
245
- echo
246
244
  echo "Branch name: $branch_name"
247
- echo
248
245
 
249
246
  # -----------------------------
250
247
  # 5. Check if branch already exists
@@ -129,7 +129,7 @@ EOF
129
129
  # 4. Extract stash ID safely
130
130
  # -----------------------------
131
131
  local stash_id
132
- stash_id=$(echo "$selection" | grep -o 'stash@{[0-9]\+}')
132
+ stash_id=$(echo "$selection" | grep -o 'stash@{[0-9]\+}' || true)
133
133
 
134
134
  if [[ -z "$stash_id" ]]; then
135
135
  echo "Error: Could not determine stash ID."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitbash",
3
- "version": "1.3.2",
3
+ "version": "1.3.4",
4
4
  "description": "Opinionated git utilities for bash with fzf-powered menus",
5
5
  "author": "jaggli",
6
6
  "license": "MIT",