Skip to content

Split pinStoreGitAttributes, copyText and trackCopied - #2430

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

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

Conversation

@annejan

@annejan annejan commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Summary

Part of #2157, batch 9. Only the structure changes: the extracted code is moved as it was, comments included.

Function CCN before after New
Pass::pinStoreGitAttributes 18 10 userAttributeLines() (9)
ClipboardManager::copyText 17 11 saveWhatWasThere() (7)
ClipboardManager::trackCopied 15 11 makeRoomInOtherCopies() (5)
  • pinStoreGitAttributes(): the walk that keeps the user's own info/attributes lines moves to userAttributeLines(), in an anonymous namespace. It still returns nothing for an empty file.
  • copyText(): the snapshot of what the clipboard held before the first secret moves to saveWhatWasThere(). The useAutoclear && restoreClipboard test stays in the caller.
  • trackCopied(): the cap of 16 on m_otherCopies, and the oldest-not-on-the-clipboard eviction, move to makeRoomInOtherCopies().
  • clipboardmanager.h now includes <QClipboard> for QClipboard::Mode.

Test plan

  • qmake6 -r CONFIG+=rnp && make -j12 && make check in a scratch HOME/GNUPGHOME: 37 suites, 2,079 passed, 0 failed
  • doxygen Doxyfile: no warnings
  • lizard -C 14: all three at or below 11

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Streamlined how clipboard history is managed and how user-authored Git attributes are preserved. Existing clipboard history limits and behavior remain unchanged, and Git attribute file-writing behavior is unaffected. No new user-facing features or changes to existing functionality are included.

Part of #2157. Behaviour-preserving extractions, comments moved verbatim:

- Pass::pinStoreGitAttributes (CCN 18 to 10): the walk that keeps the
  user's own info/attributes lines moves to userAttributeLines() (9), in
  an anonymous namespace.
- ClipboardManager::copyText (CCN 17 to 11): the snapshot of what the
  clipboard held before moves to saveWhatWasThere() (7).
- ClipboardManager::trackCopied (CCN 15 to 11): the cap on m_otherCopies
  moves to makeRoomInOtherCopies() (5).

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

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change extracts clipboard snapshot, tracked-copy eviction, and Git attribute preservation logic into helpers. The summaries report that the existing clipboard limits, safety checks, and Git attribute file-writing behavior remain unchanged.

Changes: Clipboard Helpers

Layer / File(s) Summary
Clipboard snapshot and tracked-copy helpers
src/clipboardmanager.h, src/clipboardmanager.cpp
copyText delegates snapshot selection and safety checks to saveWhatWasThere. trackCopied delegates eviction to makeRoomInOtherCopies, which retains the 16-entry limit and preserves text present in either clipboard mode.

Git Attribute Helper

Layer / File(s) Summary
Git attribute line preservation
src/pass.cpp
userAttributeLines preserves user-authored lines while removing the QtPass-managed block and trailing blank lines. pinStoreGitAttributes uses the helper.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Possibly related issues

Possibly related PRs

  • IJHack/QtPass#2090 — That PR added the clipboard snapshot logic that this change moves into saveWhatWasThere.

Suggested reviewers: nogeenhenk

Merge Risk: Minimal · up to 9e7af

This refactor extracts helper functions without changing clipboard or Git attribute behavior. It is low risk and ready to merge.

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 "Split pinStoreGitAttributes, copyText and trackCopied" matches the changeset. The PR moves the user-attribute retention logic in Pass::pinStoreGitAttributes into userAttributeLines(), moves…
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 "Split pinStoreGitAttributes, copyText and trackCopied" matches the changeset. The PR moves the user-attribute retention logic in Pass::pinStoreGitAttributes into userAttributeLines(), moves the pre-secret clipboard snapshot in ClipboardManager::copyText into saveWhatWasThere(), and moves the 16-item cap and eviction in trackCopied into makeRoomInOtherCopies(). The title names all three refactored functions, so it summarizes the main change. It is a behavior-preserving refactor, which the title does not state, but the title does not need to cover every detail.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
Fix failing CI checks

  • 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 clipboard with care,
Then tucks old copies out of there.
Git lines keep their user-made place,
While helpers tidy up the space.
I nibble a carrot and hop with grace.

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: 3b4bd3fa-ed41-45f0-954f-8fa77f4f38c0
Commits

Reviewing files that changed from the base of the PR and between 9ec41c8 and 9e7afff.

Files selected for processing: 3

  • src/clipboardmanager.cpp
  • src/clipboardmanager.h
  • src/pass.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.508% (-0.004%) from 94.512% — refactor/complexity-2157-b9 into main

@annejan

annejan commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor
Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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 9e7afff. The ninth refactor for #2157; only the structure changes.

  • Pass::pinStoreGitAttributes: userAttributeLines() is the old walk unchanged, the empty-file case and the trailing blank lines included; the write after it is as before.
  • ClipboardManager::copyText: saveWhatWasThere() is the old snapshot, still taken once per window and only under useAutoclear && restoreClipboard, before forgetIfSaved() and the copy.
  • ClipboardManager::trackCopied: makeRoomInOtherCopies() is the old cap of 16 with the same eviction (never a text still on the clipboard or in the selection), still before the append.

Nothing to add.


Generated by Claude Code

@annejan
annejan merged commit 11c8c20 into main Dec 1, 2026
39 of 40 checks passed
@annejan
annejan deleted the refactor/complexity-2157-b9 branch December 1, 2026 09:58
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