Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 14f87ca

Browse files
committedSep 30, 2024·
Address Feedback From PR Review
1 parent e8cb2aa commit 14f87ca

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed
 

Diff for: ‎README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ If you're already familiar with shell scripting and the Unix toolset, here is a
4848
| `jq` | [`JQ`](https://pkg.go.dev/github.com/bitfield/script#Pipe.JQ) |
4949
| `ls` | [`ListFiles`](https://pkg.go.dev/github.com/bitfield/script#ListFiles) |
5050
| `sed` | [`Replace`](https://pkg.go.dev/github.com/bitfield/script#Pipe.Replace) / [`ReplaceRegexp`](https://pkg.go.dev/github.com/bitfield/script#Pipe.ReplaceRegexp) |
51-
| `sha256sum` | [`SHA256Sum`](https://pkg.go.dev/github.com/bitfield/script#Pipe.SHA256Sum) / [`SHA256Sums`](https://pkg.go.dev/github.com/bitfield/script#Pipe.SHA256Sums) |
51+
| `sha256sum` | [`Hash`](https://pkg.go.dev/github.com/bitfield/script#Pipe.Hash) / [`HashSums`](https://pkg.go.dev/github.com/bitfield/script#Pipe.HashSums) |
5252
| `tail` | [`Last`](https://pkg.go.dev/github.com/bitfield/script#Pipe.Last) |
5353
| `tee` | [`Tee`](https://pkg.go.dev/github.com/bitfield/script#Pipe.Tee) |
5454
| `uniq -c` | [`Freq`](https://pkg.go.dev/github.com/bitfield/script#Pipe.Freq) |
@@ -328,7 +328,6 @@ Filters are methods on an existing pipe that also return a pipe, allowing you to
328328
| [`RejectRegexp`](https://pkg.go.dev/github.com/bitfield/script#Pipe.RejectRegexp) | lines not matching given regexp |
329329
| [`Replace`](https://pkg.go.dev/github.com/bitfield/script#Pipe.Replace) | matching text replaced with given string |
330330
| [`ReplaceRegexp`](https://pkg.go.dev/github.com/bitfield/script#Pipe.ReplaceRegexp) | matching text replaced with given string |
331-
| [`SHA256Sums`](https://pkg.go.dev/github.com/bitfield/script#Pipe.SHA256Sums) | SHA-256 hashes of each listed file |
332331
| [`Tee`](https://pkg.go.dev/github.com/bitfield/script#Pipe.Tee) | input copied to supplied writers |
333332

334333
Note that filters run concurrently, rather than producing nothing until each stage has fully read its input. This is convenient for executing long-running commands, for example. If you do need to wait for the pipeline to complete, call [`Wait`](https://pkg.go.dev/github.com/bitfield/script#Pipe.Wait).
@@ -344,7 +343,6 @@ Sinks are methods that return some data from a pipe, ending the pipeline and ext
344343
| [`Hash`](https://pkg.go.dev/github.com/bitfield/script#Pipe.Hash) | | hash, error |
345344
| [`CountLines`](https://pkg.go.dev/github.com/bitfield/script#Pipe.CountLines) | |number of lines, error |
346345
| [`Read`](https://pkg.go.dev/github.com/bitfield/script#Pipe.Read) | given `[]byte` | bytes read, error |
347-
| [`SHA256Sum`](https://pkg.go.dev/github.com/bitfield/script#Pipe.SHA256Sum) | | SHA-256 hash, error |
348346
| [`Slice`](https://pkg.go.dev/github.com/bitfield/script#Pipe.Slice) | | data as `[]string`, error |
349347
| [`Stdout`](https://pkg.go.dev/github.com/bitfield/script#Pipe.Stdout) | standard output | bytes written, error |
350348
| [`String`](https://pkg.go.dev/github.com/bitfield/script#Pipe.String) | | data as `string`, error |

Diff for: ‎script.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,7 @@ func (p *Pipe) Get(url string) *Pipe {
653653

654654
// Hash returns the hex-encoded hash of the entire contents of the
655655
// pipe based on the provided hasher, or an error.
656+
// To perform hashing on files, see [Pipe.HashSums].
656657
func (p *Pipe) Hash(hasher hash.Hash) (string, error) {
657658
if p.Error() != nil {
658659
return "", p.Error()
@@ -668,6 +669,7 @@ func (p *Pipe) Hash(hasher hash.Hash) (string, error) {
668669
// HashSums reads paths from the pipe, one per line, and produces the
669670
// hex-encoded hash of each corresponding file based on the provided hasher,
670671
// one per line. Any files that cannot be opened or read will be ignored.
672+
// To perform hashing on the contents of the pipe, see [Pipe.Hash].
671673
func (p *Pipe) HashSums(hasher hash.Hash) *Pipe {
672674
return p.FilterScan(func(line string, w io.Writer) {
673675
f, err := os.Open(line)
@@ -849,7 +851,7 @@ func (p *Pipe) SetError(err error) {
849851

850852
// SHA256Sum returns the hex-encoded SHA-256 hash of the entire contents of the
851853
// pipe, or an error.
852-
// Deprecated: SHA256Sums has been deprecated by Hash. To get the SHA 256
854+
// Deprecated: SHA256Sum has been deprecated by [Pipe.Hash]. To get the SHA 256
853855
// hash for the contents of the pipe, call `Hash(sha256.new())`
854856
func (p *Pipe) SHA256Sum() (string, error) {
855857
return p.Hash(sha256.New())
@@ -858,7 +860,7 @@ func (p *Pipe) SHA256Sum() (string, error) {
858860
// SHA256Sums reads paths from the pipe, one per line, and produces the
859861
// hex-encoded SHA-256 hash of each corresponding file, one per line. Any files
860862
// that cannot be opened or read will be ignored.
861-
// Deprecated: SHA256Sums has been deprecated by HashSums. To get the SHA 256
863+
// Deprecated: SHA256Sums has been deprecated by [Pipe.HashSums]. To get the SHA 256
862864
// encoding for the paths in the pipe, call `HashSums(sha256.new())`
863865
func (p *Pipe) SHA256Sums() *Pipe {
864866
return p.HashSums(sha256.New())

Diff for: ‎script_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -2047,7 +2047,6 @@ func TestHash_OutputsCorrectHash(t *testing.T) {
20472047
want: "788542cb92d37f67e187992bdb402fdfb68228a1802947f74c6576e04790a688",
20482048
},
20492049
}
2050-
20512050
for _, tc := range tcs {
20522051
t.Run(tc.name, func(t *testing.T) {
20532052
got, err := script.Echo(tc.input).Hash(tc.hasher)

0 commit comments

Comments
 (0)
Please sign in to comment.