Skip to content

Commit 2707555

Browse files
committed
Додавання команди для оновлення поточної гілки з основної
У програму додано нову дію — «Отримати зміни з основної гілки» (`PullDefaultBranch`). Вона дозволяє швидко оновити поточну робочу гілку змінами з головної гілки вашого проєкту (наприклад, з `main` або `master`), не перемикаючись на неї вручну. Ключові зміни: * Додано нове сполучення клавіш `Ctrl+G, Ctrl+Down` для швидкого запуску цієї дії. * У панелі Git реалізовано автоматичне визначення основної гілки для поточного сховища. * Додано інтелектуальну обробку конфліктів при злитті: якщо оновлення не вдається через конфлікти, програма тепер не просто повідомляє про помилку, а відразу відкриває інтерфейс для їх вирішення. * Оновлено механізм виконання Git-команд для кращої взаємодії з інтерфейсом користувача.
1 parent 818dd24 commit 2707555

10 files changed

Lines changed: 450 additions & 7 deletions

File tree

‎assets/keymaps/default-linux.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,7 @@
10591059
"ctrl-g up": "git::Push",
10601060
"ctrl-g down": "git::Pull",
10611061
"ctrl-g shift-down": "git::PullRebase",
1062+
"ctrl-g ctrl-down": "git::PullDefaultBranch",
10621063
"ctrl-g shift-up": "git::ForcePush",
10631064
"ctrl-g d": "git::Diff",
10641065
"ctrl-g backspace": "git::RestoreTrackedFiles",

‎assets/keymaps/default-macos.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,6 +1137,7 @@
11371137
"ctrl-g up": "git::Push",
11381138
"ctrl-g down": "git::Pull",
11391139
"ctrl-g shift-down": "git::PullRebase",
1140+
"ctrl-g ctrl-down": "git::PullDefaultBranch",
11401141
"ctrl-g shift-up": "git::ForcePush",
11411142
"ctrl-g d": "git::Diff",
11421143
"ctrl-g backspace": "git::RestoreTrackedFiles",

‎assets/keymaps/default-windows.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,7 @@
10541054
"ctrl-g up": "git::Push",
10551055
"ctrl-g down": "git::Pull",
10561056
"ctrl-g shift-down": "git::PullRebase",
1057+
"ctrl-g ctrl-down": "git::PullDefaultBranch",
10571058
"ctrl-g shift-up": "git::ForcePush",
10581059
"ctrl-g d": "git::Diff",
10591060
"ctrl-g backspace": "git::RestoreTrackedFiles",

‎crates/fs/src/fake_git_repo.rs‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ pub struct FakeGitRepositoryState {
7373
pub simulated_index_write_error_message: Option<String>,
7474
pub simulated_create_worktree_error: Option<String>,
7575
pub simulated_graph_error: Option<String>,
76+
pub simulated_pull_error: Option<String>,
77+
pub simulated_pull_stdout: String,
7678
pub branches_requiring_force_delete: HashSet<String>,
7779
pub worktrees_requiring_force_delete: HashSet<PathBuf>,
7880
pub refs: HashMap<String, String>,
@@ -94,6 +96,8 @@ impl FakeGitRepositoryState {
9496
simulated_index_write_error_message: Default::default(),
9597
simulated_create_worktree_error: Default::default(),
9698
simulated_graph_error: None,
99+
simulated_pull_error: None,
100+
simulated_pull_stdout: Default::default(),
97101
branches_requiring_force_delete: Default::default(),
98102
worktrees_requiring_force_delete: Default::default(),
99103
refs: HashMap::from_iter([("HEAD".into(), "abc".into())]),
@@ -1112,7 +1116,15 @@ impl GitRepository for FakeGitRepository {
11121116
_env: Arc<HashMap<String, String>>,
11131117
_cx: AsyncApp,
11141118
) -> BoxFuture<'_, Result<git::repository::RemoteCommandOutput>> {
1115-
unimplemented!()
1119+
self.with_state_async(false, move |state| {
1120+
if let Some(error) = &state.simulated_pull_error {
1121+
anyhow::bail!("{error}");
1122+
}
1123+
Ok(git::repository::RemoteCommandOutput {
1124+
stdout: state.simulated_pull_stdout.clone(),
1125+
stderr: String::new(),
1126+
})
1127+
})
11161128
}
11171129

11181130
fn fetch(

‎crates/fs/src/fs.rs‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2213,6 +2213,14 @@ impl FakeFs {
22132213
.unwrap();
22142214
}
22152215

2216+
pub fn set_pull_outcome_for_repo(&self, dot_git: &Path, stdout: &str, error: Option<&str>) {
2217+
self.with_git_state(dot_git, true, |state| {
2218+
state.simulated_pull_stdout = stdout.to_owned();
2219+
state.simulated_pull_error = error.map(str::to_owned);
2220+
})
2221+
.unwrap();
2222+
}
2223+
22162224
pub fn set_index_for_repo(&self, dot_git: &Path, index_state: &[(&str, String)]) {
22172225
self.with_git_state(dot_git, true, |state| {
22182226
state.index_contents.clear();

‎crates/git/src/git.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ actions!(
9494
Pull,
9595
/// Pulls changes from the remote repository with rebase.
9696
PullRebase,
97+
/// Pulls the repository's default branch into the current branch.
98+
PullDefaultBranch,
9799
/// Fetches changes from the remote repository.
98100
Fetch,
99101
/// Fetches changes from a specific remote.

0 commit comments

Comments
 (0)