Uh oh!
There was an error while loading. Please reload this page.
Fix #350 Hash directory also hashes untracked files - #895
Conversation
📝 WalkthroughWalkthroughThis PR makes dfetch ignore VCS-ignored files when detecting local changes: it adds per-repo ignored-files helpers, threads ignore lists through check/update commands, updates VCS change detection to respect ignore lists, and updates tests and BDD steps accordingly. Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as dfetch CLI
participant Cmd as Command (update/check)
participant Common as files_to_ignore()
participant Repo as Repo (Git/SVN)
participant VCS as VCS layer
participant FS as Local FS
CLI->>Cmd: run update/check [--force]
Cmd->>Common: files_to_ignore(project.destination)
Common->>Repo: repo.ignored_files(project.destination)
Repo->>FS: query ignored files (git/svn)
FS-->>Repo: ignored files list
Repo-->>Common: ignored files
Common-->>Cmd: files_to_ignore list
Cmd->>VCS: update/check(force, files_to_ignore)
VCS->>VCS: _are_there_local_changes(files_to_ignore)
VCS->>FS: compute current tree hash (exclude files_to_ignore)
FS-->>VCS: computed hash
alt local changes detected and not forced
VCS-->>Cmd: report skipped (local changes)
Cmd-->>CLI: skipped message
else no local changes or forced
VCS->>Repo: fetch/update remote
Repo-->>VCS: fetched
VCS-->>Cmd: updated
Cmd-->>CLI: success message
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (21)
💤 Files with no reviewable changes (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (7)
🧰 Additional context used🧠 Learnings (2)📓 Common learnings📚 Learning: 2025-12-31T10:55:20.972ZApplied to files:
🧬 Code graph analysis (5)tests/test_update.py (1)
dfetch/commands/update.py (2)
dfetch/commands/check.py (3)
dfetch/project/vcs.py (2)
features/steps/svn_steps.py (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (15)
🔇 Additional comments (17)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
9021e87 to
0d3b3bcCompareThere was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
dfetch/commands/update.py (1)
191-201: Extract_files_to_ignoretodfetch/commands/common.py.This static method is duplicated identically in both
update.pyandcheck.py. Move it to the existingcommon.pymodule and update imports in both files.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (14)
CHANGELOG.rstdfetch/commands/check.pydfetch/commands/update.pydfetch/project/svn.pydfetch/project/vcs.pydfetch/vcs/git.pyfeatures/guard-against-overwriting-git.featurefeatures/guard-against-overwriting-svn.featurefeatures/guard-against-overwriting.featurefeatures/steps/generic_steps.pyfeatures/steps/git_steps.pyfeatures/steps/svn_steps.pytests/test_update.pytests/test_vcs.py
💤 Files with no reviewable changes (2)
- features/guard-against-overwriting.feature
- features/steps/git_steps.py
🧰 Additional context used
🧬 Code graph analysis (6)
dfetch/vcs/git.py (2)
dfetch/util/util.py (1)
in_directory(66-75)dfetch/util/cmdline.py (1)
run_on_cmdline(38-69)
dfetch/project/vcs.py (1)
dfetch/project/abstract_check_reporter.py (1)
AbstractCheckReporter(9-91)
dfetch/project/svn.py (3)
dfetch/vcs/git.py (1)
ignored_files(348-368)dfetch/util/util.py (1)
in_directory(66-75)dfetch/util/cmdline.py (1)
run_on_cmdline(38-69)
tests/test_vcs.py (2)
dfetch/manifest/project.py (1)
vcs(406-408)dfetch/project/vcs.py (1)
_are_there_local_changes(349-361)
features/steps/svn_steps.py (1)
dfetch/util/util.py (1)
in_directory(66-75)
dfetch/commands/update.py (6)
dfetch/project/svn.py (3)
SvnRepo(42-450)ignored_files(435-450)check_path(146-153)dfetch/manifest/project.py (2)
vcs(406-408)destination(381-383)dfetch/vcs/git.py (4)
GitLocalRepo(175-501)is_git(45-61)is_git(184-191)ignored_files(348-368)dfetch/commands/check.py (1)
_files_to_ignore(134-143)dfetch/project/__init__.py (1)
make(11-22)dfetch/project/vcs.py (1)
update(95-146)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (18)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Publish Python distribution 📦 to TestPyPI
- GitHub Check: test (windows-latest, 3.11)
- GitHub Check: test (macos-latest, 3.12)
- GitHub Check: test (ubuntu-latest, 3.10)
- GitHub Check: test (macos-latest, 3.9)
- GitHub Check: test (windows-latest, 3.14)
- GitHub Check: test (windows-latest, 3.9)
- GitHub Check: test (ubuntu-latest, 3.12)
- GitHub Check: test (windows-latest, 3.12)
- GitHub Check: test (windows-latest, 3.10)
- GitHub Check: test (ubuntu-latest, 3.9)
- GitHub Check: build (windows-latest)
- GitHub Check: build (ubuntu-latest)
- GitHub Check: test-cygwin
- GitHub Check: build (macos-latest)
- GitHub Check: DevContainer Build & Test
- GitHub Check: test
🔇 Additional comments (18)
features/steps/svn_steps.py (1)
93-96: LGTM!The new SVN tag step implementation is clean and follows established patterns in the file. It correctly uses the
in_directorycontext manager and delegates to the existingcreate_taghelper.CHANGELOG.rst (1)
22-22: LGTM!The changelog entry clearly documents the fix and properly references issue #350.
tests/test_update.py (1)
68-68: LGTM!The test correctly validates that the
updatemethod receives the newfiles_to_ignoreparameter with an empty list as the default value.dfetch/vcs/git.py (1)
347-368: LGTM!The
ignored_filesimplementation correctly usesgit ls-files --ignored --others --exclude-standardto enumerate ignored files. The method properly handles non-existent paths and follows the established patterns in the codebase.dfetch/commands/check.py (2)
24-24: LGTM!The new imports are appropriately placed and support the ignore-file handling functionality.
Also applies to: 33-33, 40-40
96-99: LGTM!The check flow correctly computes and passes the
files_to_ignorelist tocheck_for_update, assuming the VCS detection issue in_files_to_ignoreis fixed.features/guard-against-overwriting-git.feature (1)
1-47: LGTM!The BDD feature file is well-structured and comprehensively covers the guard-against-overwriting behavior for Git repositories. The three scenarios appropriately test: normal blocking on local changes, force override, and ignored files not blocking updates.
dfetch/project/svn.py (1)
434-450: LGTM!The
ignored_filesimplementation correctly usessvn status --no-ignoreto enumerate ignored files (marked with "I" status). The method properly handles non-existent paths and follows established patterns in the codebase, maintaining consistency with the Git equivalent.features/guard-against-overwriting-svn.feature (2)
39-39: Note the @wip tag on the ignored files scenario.The third scenario is marked as work-in-progress. This is acceptable, though you may want to verify that the underlying functionality works even if the test is not yet complete.
1-48: LGTM!The BDD feature file appropriately covers the guard-against-overwriting behavior for SVN repositories, mirroring the Git equivalent. The first two scenarios are complete and should provide good coverage.
tests/test_vcs.py (1)
140-140: LGTM!The test correctly passes an empty
files_to_ignorelist to match the updated method signature. This is appropriate since these test cases focus on hash comparison behavior, not the ignore functionality.dfetch/project/vcs.py (3)
95-116: LGTM!The
update()method correctly:
- Accepts an optional
files_to_ignoreparameter withNonedefault- Defaults to an empty list when not provided
- Passes the ignore list to
_are_there_local_changes()to exclude VCS-ignored files from the local change detectionThis properly addresses the issue where untracked/ignored files were incorrectly causing the directory hash to differ.
159-161: LGTM!The
check_for_update()method now requiresfiles_to_ignoreas a mandatory parameter, which is appropriate since the caller (check.py) always computes this list before calling.
349-361: LGTM!The core fix is implemented correctly here. By adding
files_to_ignoreto theskiplistpassed tohash_directory(), VCS-ignored files (e.g., files matching.gitignorepatterns) are now excluded from the hash calculation. This directly resolves the issue where untracked/ignored files incorrectly affected local change detection.features/steps/generic_steps.py (3)
124-132: LGTM!The
replace_in_file()utility is a clean helper for BDD tests. The implementation is straightforward and appropriate for test code where files are expected to exist.
157-159: LGTM!The new step definition provides a convenient way to modify file contents in feature tests, enabling scenarios that test the ignore-file behavior.
205-209: LGTM!Adding the
@givendecorator alongside the existing@whendecorator provides flexibility for test scenarios to set up local file changes either as preconditions or actions.dfetch/commands/update.py (1)
84-87: LGTM!The integration correctly computes the files to ignore before calling
update(), ensuring VCS-ignored files don't affect local change detection.
Uh oh!
There was an error while loading. Please reload this page.
0d3b3bc to
63d8e76Compare63d8e76 to
f6978d1CompareUh oh!
There was an error while loading. Please reload this page.
#350
Summary by CodeRabbit
New Features
Bug Fixes
Tests
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.