Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use LF as git end of line terminator on Windows #899

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MarkEWaite
Copy link
Contributor

Use LF as git end of line terminator on Windows

Windows virtual machines are currently configured to not use LF as their git end of line. That causes failures when spotless formats files on Windows that were originally created with Unix (LF) line termination.

This is a workaround until we update the Windows virtual machine definition to fix:

Windows virtual machines are currently configured to not use LF as their
git end of line.  That causes failures when spotless formats files on
Windows that were originally created with Unix (LF) line termination.

This is a workaround until we update the Windows virtual machine
definition to fix:

* jenkins-infra/helpdesk#3865
@MarkEWaite MarkEWaite requested a review from a team as a code owner January 10, 2025 17:04
Copy link
Contributor

@lemeurherveCB lemeurherveCB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you mentioned elsewhere, this PR should go along #898 as

plugins that use spotless will fail their builds on a Windows VM when they pass on a Windows container. Switch from container to VM makes that issue visible to more people.

Related:

Copy link

@gounthar gounthar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Mark!

@MarkEWaite
Copy link
Contributor Author

@lemeurherveCB suggested a technique that I can use to test this before it is merged. I'll do that testing before I merge it.

@jglick
Copy link
Contributor

jglick commented Jan 10, 2025

CC @jtnord

@@ -142,6 +142,8 @@ Object checkoutSCM(String repo = null) {
// Enable long paths to avoid problems with tests on Windows agents
if (!isUnix()) {
bat 'git config --global core.longpaths true'
// TODO: Remove when https://github.com/jenkins-infra/helpdesk/issues/3865 is resolved
bat 'git config --global core.eol lf'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the spotless issue is that it ends up just guessing that the line ending is native becasue there is no configuration otherwise.

The alternative (which uses windows line ends on windows, so is more like what windows would do) is to set git config --global core.autocrlf true

this should cause the files to have line ends changed on windows, and will be picked up by spotless to go "oh it is converting line ends, and I am on windows" so spotless does not end up guessing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants