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

Fix the line ending issue #11

Merged
merged 11 commits into from
Oct 11, 2023
Merged

Fix the line ending issue #11

merged 11 commits into from
Oct 11, 2023

Conversation

suvayu
Copy link
Collaborator

@suvayu suvayu commented Aug 29, 2023

Fixes #9

@soininen @PekkaSavolainen could you please check?

@soininen
Copy link
Contributor

Extra new lines are now gone but the script still seems to unnecessarily change the line endings making Git to believe that every line in pyproject.toml has been modified.

@soininen
Copy link
Contributor

Actually, I'm not sure what happens there. The line endings are correct CRLF before and after running conduct release -c release.toml but git diff HEAD~1 somehow shows modified line endings like

+[project]^M

for the entire pyproject.toml file. Why that ^M?

@soininen
Copy link
Contributor

Is this due to some Git config issue? I noticed that the commit editor that gets launched when I run conduct release is Notepad and not Notepad++ which I have set for my installed Git. Are we using a different Git here with different line ending settings?

@soininen
Copy link
Contributor

Okay, what fixes the problem is to add .gitattributes file to the Toolbox repository that defines the newline behavior explicitly. It seems to be the recommended practice anyway so I think I'll just add the files to all four repositories now.

Copy link
Contributor

@soininen soininen left a comment

Choose a reason for hiding this comment

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

The newlines seem to be working after adding .gitattributes to the Toolbox repos.

@ptsavol
Copy link
Member

ptsavol commented Aug 30, 2023

Unfortunately, I still see the problem even after .gitattributes was added. The newlines are now reported as ^M when doing git diff.

I thought gitpython might ignore my global git settings so I tried adding autocrlf = true to my local Conductor repo but that did nothing. Now, I'm wondering if it has something to do with the editor gitpython may use because it opens Notepad for me as well for editing the commit message.

@soininen
Copy link
Contributor

Unfortunately, I still see the problem even after .gitattributes was added.

Strange, I do not see any newline issues anymore on my system.

@soininen
Copy link
Contributor

I take back what I said about not having newline issues. There is something fishy still.

@suvayu
Copy link
Collaborator Author

suvayu commented Aug 30, 2023

Is this due to some Git config issue? I noticed that the commit editor that gets launched when I run conduct release is Notepad and not Notepad++ which I have set for my installed Git.

Could you tell me how this is configured? Is it whatever is returned by:

$ git config --get core.editor

What is the value of the above command for you?

Are we using a different Git here with different line ending settings?

This is a bit difficult to answer. We are using the Git repo from Python using GitPython. As far as I understand the implementation, it uses the so-called "plumbing commands", which means it's possible these commands don't check user config since they are building blocks of the Git CLI we are used to.

I'll look at the line-ending issues a bit later, I'm working on a different project today.

@ptsavol
Copy link
Member

ptsavol commented Aug 30, 2023

(conductor) C:\data\GIT\SPINETOOLBOX>git config --get core.editor
"C:\\Program Files\\Notepad++\\notepad++.exe" -multiInst -notabbar -nosession -noPlugin

So this is notepad++ as it should be and not notepad.

I'll look at the line-ending issues a bit later, I'm working on a different project today.

Sure, this is not top priority by any means.

Linux/MacOs uses LF line-endings, whereas Windows uses CRLF.  Since
some commands rewrite files while preserving line-endings, we need a
consistent environment for testing on all platforms.  So disable the
autocrlf behaviour of Git on Windows.
- respect git config core.editor
- parse EDITOR correctly with shlex (e.g. paths w/ spaces)
- find fallback editors per-platform
@suvayu suvayu merged commit 29aa873 into master Oct 11, 2023
25 checks passed
@suvayu suvayu mentioned this pull request Oct 11, 2023
2 tasks
@suvayu suvayu deleted the windows-ci branch October 11, 2023 01:09
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.

Newlines broken in output pyproject.toml
3 participants