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

feat: Mark conflicted files as unmerged #1396

Merged
merged 3 commits into from
Nov 22, 2023

Conversation

pawamoy
Copy link
Contributor

@pawamoy pawamoy commented Oct 31, 2023

This PR contains 3 commits that should not be squashed:

  • a fix for correctly parsing filenames with special characters (spaces, quotes, non-ascii) in the output of Git commands, while looking for files with conflicts during an update
  • a refactor in tests, to reuse the git_init function
  • a feature to mark files with conflict markers as unmerged ( closes Inline conflicts should use standard git markers #1350)

I pushed the fix as part of this PR because it was useful to test the feature.

@pawamoy pawamoy force-pushed the mark-conflicted-files-as-unmerged branch 3 times, most recently from b5c895d to 09ee2dd Compare October 31, 2023 17:39
Copy link

codecov bot commented Oct 31, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (99bdd11) 97.24% compared to head (6eaa71d) 97.30%.
Report is 16 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1396      +/-   ##
==========================================
+ Coverage   97.24%   97.30%   +0.05%     
==========================================
  Files          48       48              
  Lines        4423     4520      +97     
==========================================
+ Hits         4301     4398      +97     
  Misses        122      122              
Flag Coverage Δ
unittests 97.30% <100.00%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pawamoy
Copy link
Contributor Author

pawamoy commented Oct 31, 2023

Most of the feature test is boilerplate to generate conflict markers in a project. Maybe this boilerplate could be declared in a fixture instead, to allow reusing it.

tests/test_updatediff.py Outdated Show resolved Hide resolved
@pawamoy pawamoy force-pushed the mark-conflicted-files-as-unmerged branch from 09ee2dd to 0667373 Compare November 12, 2023 18:21
@pawamoy pawamoy changed the title Mark conflicted files as unmerged feat: Mark conflicted files as unmerged Nov 12, 2023
@pawamoy
Copy link
Contributor Author

pawamoy commented Nov 12, 2023

I fixed the tests for the annoying operating system.

@pawamoy pawamoy requested review from yajo and sisp November 12, 2023 18:35
Copy link
Member

@yajo yajo left a comment

Choose a reason for hiding this comment

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

This feature is very awesome!

IMHO, I'd rename a bit the last commit, to something like feat: conflicts on updates now appear as git merge conflicts, also on VSCode. This is nicer for the changelog.

Also, I think you should add the git status check on the test.

tests/test_updatediff.py Outdated Show resolved Hide resolved
@pawamoy pawamoy force-pushed the mark-conflicted-files-as-unmerged branch from 0667373 to 85ee904 Compare November 21, 2023 21:43
@pawamoy pawamoy force-pushed the mark-conflicted-files-as-unmerged branch from 85ee904 to 6eaa71d Compare November 21, 2023 21:45
@pawamoy
Copy link
Contributor Author

pawamoy commented Nov 21, 2023

Commit message updated 🙂

@yajo yajo merged commit 48d0c39 into copier-org:master Nov 22, 2023
21 checks passed
@bswck
Copy link

bswck commented Jan 12, 2024

@pawamoy Is there a way to detect conflicted files (after a copier update) within the git cli?

@pawamoy
Copy link
Contributor Author

pawamoy commented Jan 12, 2024

Hey @bswck, I'm not sure to completely understand, but once you've updated your project with latest Copier, conflicted files will look like UU filepath in git status -sb. For example:

$ git status -sb
## main...origin/main
 M .copier-answers.yml
 M .github/ISSUE_TEMPLATE/bug_report.md
 M .github/ISSUE_TEMPLATE/config.yml
 M .github/ISSUE_TEMPLATE/feature_request.md
 M CONTRIBUTING.md
 M Makefile
 M README.md
 M config/ruff.toml
 M docs/credits.md
 M docs/css/mkdocstrings.css
UU duties.py
 D mkdocs.insiders.yml
UU mkdocs.yml
UU pyproject.toml
UU scripts/gen_credits.py
 M scripts/gen_ref_nav.py
 M scripts/setup.sh
UU src/failprint/cli.py
UU tests/test_cli.py
?? config/git-changelog.toml
?? config/vscode/
?? src/failprint/debug.py

You can also list them with git ls-files --stage looking for numbers 1, 2, and 3 in the third column:

$ git ls-files --stage | grep ' [123]\s'
100644 5a3413ed756d1c659c93f5051bad886131783967 1       duties.py
100644 5a3413ed756d1c659c93f5051bad886131783967 2       duties.py
100644 5a3413ed756d1c659c93f5051bad886131783967 3       duties.py
100644 0a4ac137f01fe9c32a2eb08b012d4b4db964fec0 1       mkdocs.yml
100644 0a4ac137f01fe9c32a2eb08b012d4b4db964fec0 2       mkdocs.yml
100644 0a4ac137f01fe9c32a2eb08b012d4b4db964fec0 3       mkdocs.yml
100644 02db61bd00b273bb14055842c5907fe26b7e7910 1       pyproject.toml
100644 02db61bd00b273bb14055842c5907fe26b7e7910 2       pyproject.toml
100644 02db61bd00b273bb14055842c5907fe26b7e7910 3       pyproject.toml
100644 459f293926397cddd6966fc80344a4e87a0d0024 1       scripts/gen_credits.py
100644 459f293926397cddd6966fc80344a4e87a0d0024 2       scripts/gen_credits.py
100644 459f293926397cddd6966fc80344a4e87a0d0024 3       scripts/gen_credits.py
100644 6fff4fbc7ecb63422e569182c5a7019930f8c983 1       src/failprint/cli.py
100644 6fff4fbc7ecb63422e569182c5a7019930f8c983 2       src/failprint/cli.py
100644 6fff4fbc7ecb63422e569182c5a7019930f8c983 3       src/failprint/cli.py
100644 307fbafef475bb4048c8a714acb042f8f100cf30 1       tests/test_cli.py
100644 307fbafef475bb4048c8a714acb042f8f100cf30 2       tests/test_cli.py
100644 307fbafef475bb4048c8a714acb042f8f100cf30 3       tests/test_cli.py

@bswck
Copy link

bswck commented Jan 22, 2024

@pawamoy Thanks! It didn't work for me as I was trying to check for conflicts after staging all the files. 🤦‍♂️

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.

Inline conflicts should use standard git markers
3 participants