Skip to content

Commit 58008b8

Browse files
author
Bhavi Dhingra
committed
feat(new-command): gstashsave
1 parent 1ed50ed commit 58008b8

File tree

6 files changed

+52
-3
lines changed

6 files changed

+52
-3
lines changed

Diff for: cmd/gstashapply

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#shellcheck disable=SC1091 # Not following: ./__assertgitrepo was not specified as input
44
#shellcheck disable=SC2155 # Declare and assign separately to avoid masking return values
55

6-
source "${__CUSTOM_GIT_UTIL}"/fzf_headers/__gstash_header
6+
source "${__CUSTOM_GIT_UTIL}"/fzf_headers/gstash/__gstash_header
77
source "${__CUSTOM_GIT_UTIL}"/__assertgitrepo
88
source "${__CUSTOM_GIT_UTIL}"/__select_stash_id
99

Diff for: cmd/gstashdrop

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#shellcheck disable=SC1091 # Not following: ./__assertgitrepo was not specified as input
44
#shellcheck disable=SC2155 # Declare and assign separately to avoid masking return values
55

6-
source "${__CUSTOM_GIT_UTIL}"/fzf_headers/__gstash_header
6+
source "${__CUSTOM_GIT_UTIL}"/fzf_headers/gstash/__gstash_header
77
source "${__CUSTOM_GIT_UTIL}"/__assertgitrepo
88
source "${__CUSTOM_GIT_UTIL}"/__select_stash_id
99

Diff for: cmd/gstashpop

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#shellcheck disable=SC1091 # Not following: ./__assertgitrepo was not specified as input
44
#shellcheck disable=SC2155 # Declare and assign separately to avoid masking return values
55

6-
source "${__CUSTOM_GIT_UTIL}"/fzf_headers/__gstash_header
6+
source "${__CUSTOM_GIT_UTIL}"/fzf_headers/gstash/__gstash_header
77
source "${__CUSTOM_GIT_UTIL}"/__assertgitrepo
88
source "${__CUSTOM_GIT_UTIL}"/__select_stash_id
99

Diff for: cmd/gstashsave

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
#shellcheck disable=SC1091 # Not following: ./__assertgitrepo was not specified as input
4+
#shellcheck disable=SC2155 # Declare and assign separately to avoid masking return values
5+
6+
source "${__CUSTOM_GIT_UTIL}"/__assertgitrepo
7+
source "${__CUSTOM_GIT_UTIL}"/fzf_headers/gstash/__description_header
8+
9+
__assertgitrepo
10+
11+
function main() {
12+
13+
stashDescription="$(get_stash_description)"
14+
[ -z "${stashDescription}" ] && return
15+
16+
git stash save -u -k "${stashDescription}"
17+
gstashlist
18+
gstatus
19+
}
20+
21+
function get_stash_description() {
22+
23+
local GSTASH_DESCRIPTION_HEADER="$(__description_header)"
24+
local stashDescription="$(echo "" | grep "x" |\
25+
fzf --height 10%\
26+
--info=hidden\
27+
--bind 'enter:print-query'\
28+
--header "${GSTASH_DESCRIPTION_HEADER}")"
29+
echo "${stashDescription}"
30+
}
31+
32+
main
33+

Diff for: util/fzf_headers/gstash/__description_header

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
#shellcheck disable=SC1091 # Not following: ./__common was not specified as input
4+
5+
source "$__CUSTOM_CONSOLE_UTIL"/__common
6+
7+
function __description_header() {
8+
9+
local colorMsg="Write a short description\n\n"
10+
colorMsg="${colorMsg}${BLUE}esc:${RESET} exit"
11+
12+
local edge="----------------------------------------------------"
13+
local GSTASH_DESCRIPTION_HEADER="${edge}\n${colorMsg}\n "
14+
15+
echo -e "${GSTASH_DESCRIPTION_HEADER}"
16+
}
File renamed without changes.

0 commit comments

Comments
 (0)