Skip to content

Commit 1f9c908

Browse files
committed
111
1 parent d4c8fef commit 1f9c908

2 files changed

Lines changed: 23 additions & 19 deletions

File tree

command_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ func TestExec_ContextTimeout(t *testing.T) {
2626
ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)
2727
defer cancel()
2828

29-
// Use cmd directly with a blocking stdin so the command starts
30-
// successfully and blocks reading until the context deadline fires.
29+
// Use cmd directly with a blocking stdin so the command starts successfully and
30+
// blocks reading until the context deadline fires.
3131
c, timeoutCancel := cmd(ctx, "", []string{"hash-object", "--stdin"}, nil)
3232
defer timeoutCancel()
3333

@@ -37,10 +37,10 @@ func TestExec_ContextTimeout(t *testing.T) {
3737
})
3838
}
3939

40-
// blockingReader is an io.Reader that blocks until its cancel channel is
41-
// closed, simulating a stdin that never provides data. When cancelled it
42-
// returns io.EOF so that the stdin copy goroutine can exit cleanly,
43-
// allowing cmd.Wait() to return.
40+
// blockingReader is an io.Reader that blocks until its cancel channel is closed,
41+
// simulating a stdin that never provides data. When canceled it returns io.EOF
42+
// so that the stdin copy goroutine can exit cleanly, allowing cmd.Wait() to
43+
// return.
4444
type blockingReader struct {
4545
cancel <-chan struct{}
4646
}
@@ -53,8 +53,8 @@ func (r blockingReader) Read(p []byte) (int, error) {
5353
func TestCmd_ContextCancellation(t *testing.T) {
5454
ctx, cancel := context.WithCancel(context.Background())
5555

56-
// Cancel in the background after a short delay so the command is already
57-
// running when cancellation arrives. Close done to unblock the reader.
56+
// Cancel in the background after a short delay so the command is already running
57+
// when cancellation arrives. Close done to unblock the reader.
5858
done := make(chan struct{})
5959
go func() {
6060
time.Sleep(50 * time.Millisecond)
@@ -73,9 +73,9 @@ func TestCmd_ContextCancellation(t *testing.T) {
7373
}
7474

7575
func TestExec_DefaultTimeoutApplied(t *testing.T) {
76-
// A plain context.Background() has no deadline. The command should still
77-
// succeed because DefaultTimeout (1 min) is applied automatically and
78-
// "git version" completes well within that.
76+
// A plain context.Background() has no deadline. The command should still succeed
77+
// because DefaultTimeout is applied automatically and "git version" completes
78+
// well within that.
7979
ctx := context.Background()
8080
stdout, err := exec(ctx, "", []string{"version"}, nil)
8181
assert.NoError(t, err)

commit_archive.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,17 @@ const (
2222
// Archive creates given format of archive to the destination.
2323
func (c *Commit) Archive(ctx context.Context, format ArchiveFormat, dst string) error {
2424
prefix := filepath.Base(strings.TrimSuffix(c.repo.path, ".git")) + "/"
25-
_, err := exec(ctx, c.repo.path, []string{
26-
"archive",
27-
"--prefix=" + prefix,
28-
"--format=" + string(format),
29-
"-o", dst,
30-
"--end-of-options",
31-
c.ID.String(),
32-
}, nil)
25+
_, err := exec(ctx,
26+
c.repo.path,
27+
[]string{
28+
"archive",
29+
"--prefix=" + prefix,
30+
"--format=" + string(format),
31+
"-o", dst,
32+
"--end-of-options",
33+
c.ID.String(),
34+
},
35+
nil,
36+
)
3337
return err
3438
}

0 commit comments

Comments
 (0)