Skip to content

Commit

Permalink
fix replacement error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
piranha committed Jul 13, 2013
1 parent 5654c74 commit e8c30a7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ supported as replacement, no regexp submatch support yet (planned, though).

## Changelog

- 1.7
- Remove false error reporting about not being able to replace. I'm sorry for
messing this up
- 1.6
- Add option to not colorize output
- Remove false error reporting about parsing .gitmodules
Expand Down
8 changes: 5 additions & 3 deletions goreplace.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

const (
Author = "Alexander Solovyov"
Version = "1.6"
Version = "1.7"
)
var byteNewLine = []byte("\n")

Expand Down Expand Up @@ -194,8 +194,10 @@ func (v *GRVisitor) VisitFile(fn string, fi os.FileInfo) {
if changed {
f.Seek(0, 0)
n, err := f.Write(result)
errhandle(fmt.Errorf("Error writing replacement to file '%s': %s",
fn, err), true)
if err != nil {
errhandle(fmt.Errorf("Error writing replacement to file '%s': %s",
fn, err), true)
}
if int64(n) < fi.Size() {
err := f.Truncate(int64(n))
if err != nil {
Expand Down

0 comments on commit e8c30a7

Please sign in to comment.