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

via lines often result in git conflict #1036

Closed
graingert opened this issue Jan 21, 2020 · 4 comments · Fixed by #1237
Closed

via lines often result in git conflict #1036

graingert opened this issue Jan 21, 2020 · 4 comments · Fixed by #1237
Labels
annotations Related to packages annotations feature Request for a new feature

Comments

@graingert
Copy link
Member

What's the problem this feature will solve?

currently when adding and removing packages in multiple github PRs the # via line will conflict

Describe the solution you'd like

put each # via on a new line:

six==1.12.0 \
    --hash=sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c \
    --hash=sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73 \
    # via automat, bcrypt, cryptography, ecdsa, format-cef, grpcio, patchy, pathlib, prompt-toolkit, protobuf, pyhamcrest

instead use:

six==1.12.0 \
    --hash=sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c \
    --hash=sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73 \
    # via automat
    #   , bcrypt
    #   , cryptography
    #   , ecdsa
    #   , format-cef
    #   , grpcio
    #   , patchy
    #   , pathlib
    #   , prompt-toolkit
    #   , protobuf
    #   , pyhamcrest

Alternative Solutions

Additional context

@graingert
Copy link
Member Author

also the missing trailing slash on deps without # via lines also conflict - this would be fixed with #881

@atugushev atugushev added the feature Request for a new feature label Jan 21, 2020
@atugushev atugushev added the annotations Related to packages annotations label Apr 21, 2020
@jdufresne
Copy link
Member

I've been running into the same frustration.

This is especially noticeable on Django projects that include many Django 3rd party libraries. The Django "via" line can easily extend beyond column 200.

Proposed fix in #1237. If there is a single annotation, then it is rendered on one line, otherwise, one per line.

jdufresne added a commit that referenced this issue Nov 26, 2020
When there is more than one "via" annotation, they are now formatted one
per line. This prevents very long lines in requirements.txt output. The
very long lines often scroll beyond the width of an editor, making them
difficult to read. Worse, when these annotations change, diffs are hard
to read as the actual difference is hidden far off to the right. By
placing one annotation per line, diffs will be much more obvious. This
follows the philosophy of many automatic formatters such as Black.

To simplify the formatting and to make it more consistent, annotations
are now always on the line after the requirement, whether hashes were
generated or not.

Fixes #1036
@graingert
Copy link
Member Author

also the missing trailing slash on deps without # via lines also conflict - this would be fixed with #881

@jdufresne it looks like there's now always a missing trailing slash - this increases the chance of a merge conflict

@jdufresne
Copy link
Member

The final trailing slash doesn't make sense. The slash indicates "escape this newline, to continue the statement".

I agree that it is unfortunate that this can lead to merge conflicts, but it is still wrong placement, IMO.

For example, the text:

six==1.12.0 \
    --hash=sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c \
    --hash=sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73
    # via
    #   bcrypt
    #   cryptography

After expanding the newline escapes, should expand to:

six==1.12.0 --hash=sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c --hash=sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73
    # via
    #   bcrypt
    #   cryptography

Notice the first comment is on the next line.

It should not expand to:

six==1.12.0 --hash=sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c --hash=sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73  # via
    #   bcrypt
    #   cryptography

The final newline happens to work as the next line is a comment, but if someone disabled annotations (--no-annotate), the next line would no longer be a comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
annotations Related to packages annotations feature Request for a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants