1
0
mirror of https://github.com/golang/go synced 2024-11-18 09:44:50 -07:00

refactor/rename: allow Force to make edits within autogenerated files.

Currently, as documented, gorename fails if it would cause an edit to an
autogenerated file:

- detect and reject edits to autogenerated files (cgo, protobufs)

There are times when refactoring code where such an edit is necessary.
This CL enables such edits if Force is set (which corresponds to
gorename -force).

Change-Id: If21249ae50d61fb5b59ee6e1ecf7157aaae0260a
Reviewed-on: https://go-review.googlesource.com/118975
Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
Paul Jolly 2018-06-14 20:14:02 +01:00 committed by Alan Donovan
parent 903a227b9b
commit c6269430a5

View File

@ -494,7 +494,7 @@ func (r *renamer) update() error {
}
}
}
if len(generatedFileNames) > 0 {
if !Force && len(generatedFileNames) > 0 {
return fmt.Errorf("refusing to modify generated file%s containing DO NOT EDIT marker: %v", plural(len(generatedFileNames)), generatedFileNames)
}