Skip to content

Commit 0771a5f

Browse files
committed
Merge remote-tracking branch 'original/main' into mtls_feat
2 parents 43ba40d + 4167b1f commit 0771a5f

File tree

4 files changed

+19
-14
lines changed

4 files changed

+19
-14
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ require (
2424
github.com/spf13/viper v1.14.0
2525
github.com/stretchr/testify v1.8.1
2626
github.com/zalando/go-keyring v0.2.1
27+
golang.org/x/term v0.8.0
2728
)
2829

2930
require (
@@ -64,8 +65,7 @@ require (
6465
github.com/yuin/goldmark v1.5.3 // indirect
6566
github.com/yuin/goldmark-emoji v1.0.1 // indirect
6667
golang.org/x/net v0.7.0 // indirect
67-
golang.org/x/sys v0.5.0 // indirect
68-
golang.org/x/term v0.5.0 // indirect
68+
golang.org/x/sys v0.8.0 // indirect
6969
golang.org/x/text v0.7.0 // indirect
7070
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
7171
gopkg.in/ini.v1 v1.67.0 // indirect

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -425,14 +425,14 @@ golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBc
425425
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
426426
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
427427
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
428-
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
429-
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
428+
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
429+
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
430430
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
431431
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
432432
golang.org/x/term v0.0.0-20210503060354-a79de5458b56/go.mod h1:tfny5GFUkzUvx4ps4ajbZsCe5lw1metzhBm9T3x7oIY=
433433
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
434-
golang.org/x/term v0.5.0 h1:n2a8QNdAb0sZNpU9R1ALUXBbY+w51fCQDN+7EdxNBsY=
435-
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
434+
golang.org/x/term v0.8.0 h1:n5xxQn2i3PC0yLAbjTpNT85q/Kgzcr2gIoX9OrJUols=
435+
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
436436
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
437437
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
438438
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

internal/cmd/issue/edit/edit.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ $ jira issue edit ISSUE-1 -s"New Bug" -yHigh -lbug -lurgent -CBackend -b"Bug des
2828
# Use --no-input option to disable interactive prompt
2929
$ jira issue edit ISSUE-1 -s"New updated summary" --no-input
3030
31+
# Use pipe to read the description body directly from standard input
32+
$ echo "Description from stdin" | jira issue edit ISSUE-1 -s"New updated summary" --no-input
33+
3134
# Use minus (-) to remove label, component or fixVersion
3235
$ jira issue edit ISSUE-1 --label -urgent --component -BE --fix-version -v1.0`
3336
)
@@ -96,6 +99,14 @@ func edit(cmd *cobra.Command, args []string) {
9699
getAnswers(params, issue)
97100
}
98101

102+
// Use stdin only if nothing is passed to --body
103+
if params.body == "" && cmdutil.StdinHasData() {
104+
b, err := cmdutil.ReadFile("-")
105+
if err != nil {
106+
cmdutil.Failed("Error: %s", err)
107+
}
108+
params.body = string(b)
109+
}
99110
// Keep body as is if there were no changes.
100111
if params.body != "" && params.body == originalBody {
101112
params.body = ""

internal/cmdutil/utils.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/fatih/color"
1313
"github.com/mitchellh/go-homedir"
1414
"github.com/spf13/viper"
15+
"golang.org/x/term"
1516

1617
"github.com/ankitpokhrel/jira-cli/pkg/browser"
1718
"github.com/ankitpokhrel/jira-cli/pkg/jira"
@@ -129,14 +130,7 @@ func GetConfigHome() (string, error) {
129130

130131
// StdinHasData checks if standard input has any data to be processed.
131132
func StdinHasData() bool {
132-
fi, err := os.Stdin.Stat()
133-
if err != nil {
134-
return false
135-
}
136-
if fi.Mode()&os.ModeNamedPipe == 0 {
137-
return false
138-
}
139-
return true
133+
return !term.IsTerminal(int(os.Stdin.Fd()))
140134
}
141135

142136
// ReadFile reads contents of the given file.

0 commit comments

Comments
 (0)