F1: remote checkout without a remote, git.lastMessage, shared git status store
- vcs: checking out a remote-tracking branch reads remote.<name>.fetch; without a matching refspec it creates the local branch with --no-track instead of leaving a dirty tree after git fails to set up tracking. - vcs + engine: git.lastMessage returns HEAD's full message (null before the first commit); the Changes window prefills Amend with it. - ui: stores/vcsStatus.ts is the only git.status caller; the Changes window, tree/tab colours and the branch item read its snapshot, so a gitChanged costs one status query. RepoSummary carries upstream, ahead and behind. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
d567f3957d
commit
4bdfe521f2
14 changed files with 649 additions and 314 deletions
|
|
@ -351,6 +351,60 @@ fn remote_branches_are_listed_and_checked_out_as_tracking_branches() {
|
|||
repo.checkout("origin/remote-only").unwrap();
|
||||
let branches = repo.branches().unwrap();
|
||||
assert_eq!(branches.current.as_deref(), Some("remote-only"));
|
||||
let local = branches.local.iter().find(|b| b.name == "remote-only");
|
||||
assert_eq!(
|
||||
local.and_then(|b| b.upstream.as_deref()),
|
||||
Some("origin/remote-only")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn remote_branches_without_a_configured_remote_check_out_untracked_and_clean() {
|
||||
let Some(cli) = installed() else { return };
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
init(dir.path());
|
||||
write(dir.path(), "a.php", "<?php\n");
|
||||
git(dir.path(), &["add", "-A"]);
|
||||
git(dir.path(), &["commit", "-q", "-m", "base"]);
|
||||
git(dir.path(), &["checkout", "-q", "-b", "gone"]);
|
||||
write(dir.path(), "b.php", "<?php // only on gone\n");
|
||||
git(dir.path(), &["add", "-A"]);
|
||||
git(dir.path(), &["commit", "-q", "-m", "gone"]);
|
||||
git(dir.path(), &["checkout", "-q", "main"]);
|
||||
git(dir.path(), &["update-ref", "refs/remotes/old/gone", "gone"]);
|
||||
git(dir.path(), &["branch", "-q", "-D", "gone"]);
|
||||
let repo = open(&cli, dir.path());
|
||||
|
||||
repo.checkout("old/gone").unwrap();
|
||||
let status = repo.status().unwrap();
|
||||
assert_eq!(status.head.branch.as_deref(), Some("gone"));
|
||||
assert_eq!(status.head.upstream, None);
|
||||
assert!(status.files.is_empty(), "{:?}", status.files);
|
||||
assert!(dir.path().join("b.php").exists());
|
||||
|
||||
repo.checkout("main").unwrap();
|
||||
let err = repo.checkout("old/gone").unwrap_err();
|
||||
assert!(matches!(err, VcsError::Git(_)), "{err:?}");
|
||||
let status = repo.status().unwrap();
|
||||
assert_eq!(status.head.branch.as_deref(), Some("main"));
|
||||
assert!(status.files.is_empty(), "{:?}", status.files);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_last_message_prefills_an_amend() {
|
||||
let Some(cli) = installed() else { return };
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
init(dir.path());
|
||||
let repo = open(&cli, dir.path());
|
||||
assert_eq!(repo.last_message().unwrap(), None);
|
||||
write(dir.path(), "a.php", "<?php\n");
|
||||
repo.stage(&["a.php".into()]).unwrap();
|
||||
repo.commit("Subject line\n\n# kept\nBody ü\n\n", false)
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
repo.last_message().unwrap().as_deref(),
|
||||
Some("Subject line\n\n# kept\nBody ü")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue