Skip to content

Commit

Permalink
build: prevent eol modification in vendored code
Browse files Browse the repository at this point in the history
When 'dep ensure -vendor-only' is run, dep will update the dependencies
in the vendor directory to match what's referenced in Gopkg.lock. It
does this without performing EOL modification.

Even if there are no changes to the dependencies, this shows up as
pending changes in tree.

```
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   vendor/github.com/Knetic/govaluate/LICENSE
	modified:   vendor/github.com/konsorten/go-windows-terminal-sequences/LICENSE
```

When you run `git diff` to see the changes, warnings like the following are
issued:

```
warning: CRLF will be replaced by LF in
vendor/github.com/Knetic/govaluate/LICENSE.
The file will have its original line endings in your working directory.
```

This is telling us that when we add the changes to the index, git will
convert the CRLF to LF leaving is with no changes in the index and
nothing to commit.

We can prevent this confusion by disabling the automatic text conversion
for files in the vendor folder.

This change disables text conversion for vendor/** and re-adds the files
with CRLF from our vendor tree.

Signed-off-by: Matthew Sykes <[email protected]>
  • Loading branch information
sykesm committed Apr 13, 2020
1 parent a53a796 commit 24d018e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 21 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
*.yml text eol=lf
*.zip binary
LICENSE text eol=lf
vendor/** -text
42 changes: 21 additions & 21 deletions vendor/github.com/Knetic/govaluate/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 24d018e

Please sign in to comment.