Commit Graph

37 Commits

Author SHA1 Message Date
Levi Neely b758859c3c Support default= in .kateworkspace to set initial subrepo 2026-07-23 16:16:43 +02:00
Levi Neely ac5af7b6d6 Fix branch compare: use two-dot diff, preserve +/* display prefixes 2026-07-23 16:11:38 +02:00
Levi Neely 6e8e2845a0 Fix branch name parsing: strip + prefix from worktree branches 2026-07-23 16:07:01 +02:00
Levi Neely b8218878c5 add diff action extension mechanism for external plugins
Expose Q_PROPERTY lastDiff, signal diffShown(), and Q_INVOKABLE
registerDiffAction() so other KTextEditor plugins (e.g. ollie) can
register actions that appear in the tree view context menu.

When a registered action is picked, computeDiffForFiles() runs
git diff synchronously for the selected files before triggering
the action, ensuring the consumer always gets a fresh diff
regardless of whether the user previously viewed it.
2026-07-23 14:52:56 +02:00
Levi Neely dcc5218ad7 Add context menu to status tree: View Diff(s), Open File(s) 2026-07-23 14:34:36 +02:00
Levi Neely 63bc6680c4 Remove debug tooltip marker 2026-07-23 09:04:07 +02:00
Levi Neely 28746d5363 Remove auto-generation of .kateworkspace
Auto-generating .kateworkspace in detectWorkspace() was causing false
positives: it would create the marker in unrelated parent directories,
then detect them as workspaces on subsequent runs. The .kateworkspace
file should only be created explicitly via Create Workspace.
2026-07-23 09:03:46 +02:00
Levi Neely c2bbb81767 debug: add version marker to combo tooltip 2026-07-23 09:00:01 +02:00
Levi Neely b06d4dbe2f Detect workspace changes in updateStatus
When projectBaseDir() returns a different path, re-run detectWorkspace()
and setupFileWatcher(). This catches project switches regardless of
which signal triggers the refresh (viewChanged, doc save, timer, etc.).
2026-07-23 08:58:22 +02:00
Levi Neely 1d89a5652d Always re-detect workspace on project change
Remove the newDir != m_gitDir guard in onProjectChanged so workspace
detection always runs when the project switches, regardless of whether
projectBaseDir() returns the same path.
2026-07-23 08:53:41 +02:00
Levi Neely 1840a8cea9 Fix project-switch signal: use projectFileNameChanged
The Kate project plugin emits projectFileNameChanged (not projectChanged)
when the active project switches. The previous signal name silently
failed to connect at runtime.
2026-07-23 08:52:48 +02:00
Levi Neely 1c81cd9cf5 Connect to project plugin projectChanged signal
Listen for Kate project switches via kateprojectplugin projectChanged()
signal. When fired, re-detect workspace and refresh all state. This
ensures the repo combo hides when switching to a non-workspace project.
2026-07-23 08:51:10 +02:00
Levi Neely 5f3cb89b58 Clear combo and workspace list when leaving workspace mode
Ensure repo combo and workspace list are cleared (not just hidden)
when switching to a non-workspace project.
2026-07-23 08:48:22 +02:00
Levi Neely 5cec45d755 Remove heuristic workspace detection
Workspace detection now relies solely on .kateworkspace marker files
or .gitmodules. The heuristic (2+ sibling git repos) caused false
positives when a standalone repo lived in a directory alongside other
repos (e.g. ~/src/).
2026-07-23 08:45:39 +02:00
Levi Neely 57895bcc48 README: fix auto-refresh description (refs/heads, not index) 2026-07-22 19:29:23 +02:00
Levi Neely dd8a2b8a36 Add GPLv3+ license and update README 2026-07-22 19:14:40 +02:00
Levi Neely f00fede797 docs: rewrite intro to lead with complex project support 2026-07-22 19:05:39 +02:00
Levi Neely 234817969d docs: add workspaces documentation to README 2026-07-22 19:00:57 +02:00
Levi Neely 60d86ab690 Include remote branches in workspace create auto-completion
The destination completer now lists both local and remote branches
(with remote prefix stripped for convenience). Fan-out logic checks
for remote tracking branches: if a branch exists on a remote but not
locally, creates a local tracking branch from it.
2026-07-22 16:59:24 +02:00
Levi Neely 9b1de56e97 Add branch auto-completion to create workspace dialog
Destination field offers completion from all branch names found across
repos in the source workspace. Uses MatchContains for substring matching.
Completer updates when source path changes.

Existing fan-out logic already handles checkout-vs-create per repo:
if branch exists in a repo, checks it out; otherwise creates it.
2026-07-22 16:56:16 +02:00
Levi Neely cd123422f9 Replace createWorkspace with proper dialog
Dialog has Source field (with Browse button, defaults to workspace source)
and Destination field (workspace name = branch name). OK/Cancel buttons.
2026-07-22 16:28:10 +02:00
Levi Neely fe4c618780 Fix .kateproject generation: per-repo, not workspace-level
Kate project plugin needs .kateproject in each repo subdir for project
switching to work. A workspace-level .kateproject makes Kate treat the
whole workspace as one project, breaking repo switching.
2026-07-22 16:22:14 +02:00
Levi Neely c520e46cf5 Show "No git repository" instead of staying on "initializing" 2026-07-22 16:19:54 +02:00
Levi Neely f1ffad7eb8 Clear git state when project is closed
When viewChanged fires with no active project/document, reset all git
state, hide workspace controls, and show "No project" in the repo label.
2026-07-22 16:16:23 +02:00
Levi Neely 55b4fef0a0 Auto-generate .kateworkspace and .kateproject when opening a workspace
If a workspace is detected (heuristic or submodule) but lacks these files,
generate them automatically so Kate project detection works and workspace
metadata is established for future operations.
2026-07-22 16:13:52 +02:00
Levi Neely 029b1885a6 Add workspace support: multi-repo detection, create, remove, prune
Supports directories containing multiple git repos grouped by task/release.
Detects workspaces via .kateworkspace marker, .gitmodules (submodule monorepo),
or heuristic (2+ sibling git repos in parent dir).

New Workspaces tab lists peer workspaces with branch info.
Repo combo box switches active repo within a workspace.

.kateworkspace format (INI):
  [workspace]
  source=.         # primary
  source=../r7.20  # derived
  [hooks]
  OnRemove=<cleanup command> %d

Create workspace: pick source dir, enter name (=branch), fans out
git worktree add across all repos, copies .kateworkspace.

Remove workspace: runs OnRemove hook, git worktree remove per repo, rmdir.
Prune: git worktree prune across all source repos.
2026-07-22 16:09:07 +02:00
Levi Neely 460247e8a0 fix index.lock sticking: drop .git/ and index watches, use document-save events
The QFileSystemWatcher on .git/ directory and .git/index file caused a
feedback loop: every git operation touching the index fired watch events
that triggered git-status, creating lock contention and stale
index.lock files.

Now only concrete events trigger a refresh:
- .git/HEAD file change (branch switch)
- refs/heads/ directory change (branch create/delete)
- KTextEditor document save (documentSavedOrUploaded signal)

No periodic timers. The 500ms debounce remains as the single gate.
2026-07-20 10:55:41 +02:00
Levi Neely 7098d70b40 Fix branch context menu using wrong branch for Create Worktree
Capture the right-clicked branch in lambdas at menu-build time instead
of relying on currentItem() at action execution time, which could shift
due to auto-refresh or filter interactions.
2026-07-16 11:25:45 +02:00
Levi Neely cbbb06bd53 Fix libkateprivate detection on multi-arch systems (Debian/Ubuntu)
The glob pattern only searched /usr/lib64 and /usr/lib, missing the
multi-arch path (e.g. /usr/lib/x86_64-linux-gnu/) where Debian-based
distros install the library. This caused HAVE_KATE_DIFF to never be
defined, so diffs were shown as raw text instead of using Kate built-in
diff widget.
2026-07-16 09:45:57 +02:00
Levi Neely b4e28097c8 Add git log tab, configurable tab visibility, and drag-reorderable tabs
- Log tab: shows last 200 commits, double-click to diff against HEAD,
  context menu with show commit and copy hash
- Tab visibility: right-click tab bar to toggle optional tabs
  (Branches, Stashes, Worktrees, Log); Status always visible
- Tabs are drag-reorderable; order and visibility persist via QSettings
- Branches: add Soft Reset to Merge Base context menu action
2026-07-16 08:58:47 +02:00
Levi Neely 7dabd4b9e6 Support deleting remote branches via the delete button
The delete button and context menu action now detect whether the
selected branch is remote (tracked via Qt::UserRole on list items).
Remote branches are deleted with `git push --delete <remote> <branch>`
with an appropriate confirmation dialog warning about server-side
removal. Local branches continue using `git branch -D`.
2026-07-16 05:38:10 +02:00
Levi Neely 3642f8b743 Preserve selection during auto-refresh
- Only refresh status model when git output actually changes (skip
  beginResetModel/endResetModel if raw output is identical)
- Filesystem watcher triggers updateStatus only, not refreshAll —
  branch/stash/worktree lists only rebuild on explicit user actions
- Branch list refreshes on HEAD file change (branch switch) with delay
  to avoid interrupting interactions
2026-07-16 04:42:07 +02:00
Levi Neely 3febe2f184 Fix auto-refresh: watch .git directory instead of just files
Watching individual files (.git/index, .git/HEAD) fails reliably
because git replaces them via atomic rename, which removes inotify
watches. Watch the .git directory itself via directoryChanged signal
which fires on any create/delete/rename inside it. Keep file watches
as fallback. Also watch refs/heads for branch tip changes.
2026-07-16 04:28:24 +02:00
Levi Neely a7e7542d70 Fix auto-refresh: re-add file watch after atomic replace
QFileSystemWatcher drops watches when git replaces index/HEAD via
atomic rename. Re-add the path after each fileChanged signal.
Also refresh all tabs (branches, stashes, worktrees) on fs change,
not just status.
2026-07-16 04:24:10 +02:00
Levi Neely ac8980a203 Use Kate's native diff viewer, add per-file and full changeset diff
- Integrate with libkateprivate's Utils::showDiff() to use Kate's built-in
  diff widget (respects user's Unified/SideBySide/Raw style preference)
- Add bundled kate-compat headers for DiffParams and Utils::showDiff decl
- CMakeLists.txt auto-detects libkateprivate, falls back to plain text diff
- Add 'Diff selected' button: shows diff for selected files with
  stage/unstage/discard actions available in the diff viewer
- Add 'Diff All' button: shows git diff HEAD for full changeset review
- Staged diffs show unstage action, unstaged diffs show stage+discard
- ReloadOnShow flag keeps diff views fresh after interactive operations
2026-07-16 04:21:51 +02:00
Levi Neely 163c3d18a9 Add KF6/Qt6 build support with auto-detection
CMakeLists.txt now probes for KF6TextEditor first, falls back to KF5.
Uses correct install namespace (kf6/ktexteditor vs ktexteditor).
Source code already had the necessary #if guards for KF6 constructor.
No API changes needed - KTextEditor plugin interface is identical.
2026-07-15 18:11:03 +02:00
Levi Neely ab2d531240 Git++ Kate plugin: initial release
Full-featured Git integration for Kate with tabbed side panel:

Status tab:
- Live file status tree (staged/changed/untracked)
- Stage, unstage, discard with double-click support
- Commit with inline message editor and amend support
- Push, pull, fetch with progress spinner
- Filesystem watcher for auto-refresh

Branches tab:
- Filterable list of local and remote branches
- Checkout, create, delete, compare
- Create worktree from branch
- Copy branch name to clipboard

Stashes tab:
- List all stashes with apply, pop, drop, diff

Worktrees tab:
- List active worktrees
- Create (with branch picker), remove, prune
- Open worktree as Kate project

Indicators:
- Panel header with repo/branch/dirty state
- Status bar widget always visible
- Detached HEAD warning
- Remote operation progress
2026-07-15 16:58:05 +02:00