Skip to content

Split Util::repositoryPassClimbsTo and ImitatePass::finishReencrypt - #2424

Merged
annejan merged 1 commit into
mainfrom
refactor/complexity-2157-b3
Dec 1, 2026
Merged

annejan merged 1 commit into
mainfrom
refactor/complexity-2157-b3

Conversation

@annejan

@annejan annejan commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Summary

Third batch for #2157; the code and comments move into helpers, no behaviour change.

  • Util::repositoryPassClimbsTo (CCN 39 → 12): file-local helpers in the existing non-Windows namespace next to openFollowedRegularFile():
    • gitWalkStart(), the real path git walks from (a store that does not exist yet: its nearest existing folder resolved, the rest appended);
    • passCeilingFor(), pass's GIT_CEILING_DIRECTORIES as git reads it;
    • isGitDirectory() and repositoryAt(), the former lambdas, with Found at namespace scope.
  • ImitatePass::finishReencrypt (CCN 37 → 13):
    • reportFailedEntries();
    • settleAutoPushHold(), the removed-reader record and the auto-push hold, which returns whether an entry in the run's folder is still read by someone removed;
    • reportReencryptOutcome(), the status line and the push after a run;
    • rememberUnexpected().

agreedRun is still computed in finishReencrypt() before m_reencryptAgreed is cleared, and passed on. The order of every step is unchanged.

Test plan

  • Full make check in a scratch HOME/GNUPGHOME with a Git identity: 36 suites, 0 failures
  • doxygen Doxyfile prints no warnings
  • clang-format clean
  • uv tool run lizard src/util.cpp src/imitatepass.cpp: all touched functions below CCN 15

Part of #2157.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Automatic pushes are now held after cancelled or aborted re-encryption runs, failures, or when removed recipients can still read entries. The hold is released after a clean run that does not require recipient agreement.
    • Re-encryption results continue to report failed entries, with additional failures reported beyond the 15-item display limit. Unexpected-recipient results are retained for non-cancelled, non-aborted runs.
    • Repository discovery now handles store paths containing colons more reliably while respecting repository boundaries.

Third batch for #2157 (lizard CCN 39 and 37). The code and its comments
move into helpers:

- util.cpp, file-local next to openFollowedRegularFile(): gitWalkStart()
  (the real path git walks from), passCeilingFor() (pass's
  GIT_CEILING_DIRECTORIES as git reads it), and the former lambdas
  isGitDirectory() and repositoryAt(), with the Found enum at namespace
  scope.
- ImitatePass: reportFailedEntries(), settleAutoPushHold() (the removed-
  reader record and the auto-push hold, returning whether an entry is
  still read by someone removed), reportReencryptOutcome() (status line
  and the push after a run) and rememberUnexpected().

No behaviour change. repositoryPassClimbsTo 39 -> 12, finishReencrypt
37 -> 13; every new helper is below 15.

Part of #2157.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Anne Jan Brouwer <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The PR extracts helper functions from re-encryption completion and Git repository discovery code. The re-encryption flow retains its cleanup and state updates. The repository walk retains its existing checks and stopping conditions.

Changes: Re-encryption Completion

Layer / File(s) Summary
Completion reporting and push-hold helpers
src/imitatepass.h, src/imitatepass.cpp
finishReencrypt delegates failed-entry reporting, automatic-push hold settlement, and outcome reporting to dedicated helpers. It retains cleanup, unexpected-recipient handling, deferred-push clearing, and queued-run handling.

Git Repository Discovery

Layer / File(s) Summary
Path resolution and repository checks
src/util.cpp
repositoryPassClimbsTo uses helpers to resolve the walk start, select an applicable ceiling, and detect repositories. Its upward walk retains the existing refusal, bare-repository, and ceiling checks.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor

Possibly related issues

  • IJHack/QtPass#2157: This PR splits two functions listed in the issue’s plan, but does not complete the issue.

Suggested reviewers: nogeenhenk

Merge Risk: Minimal · up to 3563a

This change moves code into helper functions for re-encryption completion and Git repository discovery, with no intended change in behavior. No concrete defect was identified, so the risk of merging is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names two functions, Util::repositoryPassClimbsTo and ImitatePass::finishReencrypt, that the changeset refactors. The objectives describe the change as splitting these functions into helpers…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names two functions, Util::repositoryPassClimbsTo and ImitatePass::finishReencrypt, that the changeset refactors. The objectives describe the change as splitting these functions into helpers with no intended behavior change. The title identifies the main change, though it says "Split" without naming the helpers.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

A rabbit checks the paths at dawn,
Then sorts the helpers neatly drawn.
It counts the entries, one by one,
And holds each push till checks are done.
The code hops on, its steps now clear,
With tidy functions gathered here.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI (base), Organization UI (inherited)
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: a7e717f3-5200-492f-9737-c41ac0240153
Commits

Reviewing files that changed from the base of the PR and between 6d80d81 and 3563ad6.

Files selected for processing: 3

  • src/imitatepass.cpp
  • src/imitatepass.h
  • src/util.cpp

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 94.533% (-0.02%) from 94.557% — refactor/complexity-2157-b3 into main

@nogeenhenk nogeenhenk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed at 3563ad6. The third refactor for #2157; as with #2417 and #2418 I checked that only the structure changes.

  • Util::repositoryPassClimbsTo: gitWalkStart() returns empty exactly where the old loop returned early (no part of the path exists), so the new start.isEmpty() check adds no case; passCeilingFor(), isGitDirectory() and repositoryAt() are the old code and lambdas unchanged, and the walk below them is identical.
  • ImitatePass::finishReencrypt: the steps run in the old order. agreedRun is still read before m_reencryptAgreed is cleared, settleAutoPushHold() returns the stillRead the status line used, and rememberUnexpected() still runs after the agreed set is cleared, as before.
  • The only removed lines that do not come back are the renamed or reshaped declarations (start, the lambdas, the Found enum moved to namespace scope) and the failure report now reading failed instead of result.failed. The tr() calls stay in ImitatePass, so translations are unchanged.

Nothing to add.


Generated by Claude Code

@annejan
annejan merged commit 214c593 into main Dec 1, 2026
33 checks passed
@annejan
annejan deleted the refactor/complexity-2157-b3 branch December 1, 2026 00:00
@annejan annejan mentioned this pull request Dec 1, 2026
29 of 40 tasks
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.

3 participants