Skip to content

Commit

Permalink
Fix auto-update thrash: change root .gitattributes (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
dagood committed Jan 26, 2022
1 parent da66f01 commit ffec155
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Treat all files in the Go repo as binary, with no git magic updating
# line endings. This produces predictable results in different environments.
#
# Windows users contributing to Go will need to use a modern version
# of git and editors capable of LF line endings.
#
# Windows .bat files are known to have multiple bugs when run with LF
# endings, and so they are checked in with CRLF endings, with a test
# in test/winbatch.go to catch problems. (See golang.org/issue/37791.)
#
# We'll prevent accidental CRLF line endings from entering the repo
# via the git-codereview gofmt checks and tests.
#
# See golang.org/issue/9281.

* -text

# NO MICROSOFT_UPSTREAM:
# The above lines in this file are the entire content of upstream's
# ".gitattributes" file. It's important that the development environment in the
# microsoft/go repo matches upstream's to avoid disrupting work on
# contributions.
#
# The below lines apply autocrlf to a few specific files and folders to make
# them work nicely with dotnet/arcade's auto-update infrastructure. These
# files/folders aren't present in upstream.
#
# "darc update" is the auto-update command for dotnet/arcade, and it updates
# file content in a way that ends up with CRLF on Windows and LF on Linux. This
# can cause thrashing when checked in without autocrlf. We fix this by adding
# normalization that matches the way Arcade expects it to work:
# https://github.com/dotnet/arcade/blob/ec35b4879466a6071c16db8fa3ce5d2dca0dfbe8/.gitattributes

/eng/common/** text=auto encoding=UTF-8
/eng/Version.Details.xml text=auto encoding=UTF-8
/eng/Versions.props text=auto encoding=UTF-8
/global.json text=auto encoding=UTF-8
/NuGet.config text=auto encoding=UTF-8

/eng/common/**/*.sh text eol=lf
# END NO MICROSOFT_UPSTREAM
15 changes: 15 additions & 0 deletions eng/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ infrastructure requirements:

* `/*.md` - The Microsoft GitHub organization has standard repository text that
needs to be in these files, so the upstream Go repo text is changed.
* `/.gitattributes` - When Arcade auto-update changes files, it uses CRLF or LF
depending on runtime/platform. The Go repo disables autocrlf, so this behavior
causes thrashing. To fix this, we modified the attributes file to turn
autocrlf back on for specific auto-updated files.
* `/.github` - Contains CI configuration. GitHub requires files to be at this
absolute path, so the files in the upstream Go repo need to be deleted to
configure Microsoft's CI.
Expand All @@ -53,6 +57,17 @@ infrastructure requirements:
* `/NuGet.config` - This is a .NET NuGet sources configuration file. This is
also required at the root of the repo by the Arcade SDK.

To find TODO-style comments describing intentional changes to upstream files
that seem suitable to contribute, search the repo for:

```
MICROSOFT_UPSTREAM
```

You will also find `NO MICROSOFT_UPSTREAM` marking changes that wouldn't be
useful to contribute to upstream. Typically, changes marked this way have no
effect whatsoever outside the context of the Microsoft-specific infrastructure.

For a complete list of files that are modified vs. the upstream Git repository,
first make sure you have the upstream Git refs locally. One way to do this is to
set up a remote:
Expand Down
1 change: 1 addition & 0 deletions eng/_util/cmd/sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ default. This avoids trampling changes in the user's clone.`
//
// This is in package scope just so it's easy to find at the top of the file for maintenance.
var autoResolveOurPaths = []string{
".gitattributes",
".github",
"CODE_OF_CONDUCT.md",
"README.md",
Expand Down

0 comments on commit ffec155

Please sign in to comment.