Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions macos/Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,7 @@
"Commit message replaced" = "Commit message replaced";
"Commit message: %@" = "Commit message: %@";
"Commit messages use" = "Commit messages use";
"Commit or stash local changes before pulling." = "Commit or stash local changes before pulling.";
"Commit title" = "Commit title";
"Commit version" = "Commit version";
"Commits" = "Commits";
Expand Down Expand Up @@ -4247,6 +4248,7 @@
"The active repository changed. Inspect the original repository before retrying." = "The active repository changed. Inspect the original repository before retrying.";
"The address is invalid." = "The address is invalid.";
"The application closed before the debug terminal could start." = "The application closed before the debug terminal could start.";
"The branch changed while choosing a pull strategy. Review it and try again." = "The branch changed while choosing a pull strategy. Review it and try again.";
"The branch could not be published" = "The branch could not be published";
"The branch now contains the completed plan. Its original history remains available through the recovery reference." = "The branch now contains the completed plan. Its original history remains available through the recovery reference.";
"The breakdown needs Model call statistics (on by default). After turning it on, reconnect and send a message." = "The breakdown needs Model call statistics (on by default). After turning it on, reconnect and send a message.";
Expand Down Expand Up @@ -4749,6 +4751,7 @@
"UNFILED CONNECTIONS" = "UNFILED CONNECTIONS";
"URL" = "URL";
"Unable to create the Maven dependency plan." = "Unable to create the Maven dependency plan.";
"Unable to inspect the branch." = "Unable to inspect the branch.";
"Unable to parse Maven dependencies for this module." = "Unable to parse Maven dependencies for this module.";
"Unable to read settings" = "Unable to read settings";
"Unable to resolve Maven dependencies." = "Unable to resolve Maven dependencies.";
Expand Down Expand Up @@ -5260,6 +5263,9 @@
"git.log.branchNameEmpty" = "Specify name for the new branch";
"git.log.branchNameHead" = "HEAD is a reserved keyword";
"git.log.olderCommitsFailed" = "Could not load older commits. Refresh history";
"git.pullResult.dirty" = "Commit or stash local changes before pulling.";
"git.pullResult.inspectBranchFailed" = "Unable to inspect the branch.";
"git.pullResult.stateChanged" = "The branch changed while choosing a pull strategy. Review it and try again.";
"git.rebasePlan.issue.emptyReword" = "Every Reword step needs a commit message.";
"git.rebasePlan.issue.emptySquash" = "Enter a Squash message or use the default combined messages.";
"git.rebasePlan.issue.invalidMessage" = "The commit messages in this plan are not valid.";
Expand Down
6 changes: 6 additions & 0 deletions macos/Resources/zh-Hans.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,7 @@
"Commit message replaced" = "提交信息已替换";
"Commit message: %@" = "提交说明:%@";
"Commit messages use" = "提交信息使用";
"Commit or stash local changes before pulling." = "拉取前请先提交或贮藏本地更改。";
"Commit title" = "提交标题";
"Commit version" = "提交版本";
"Commits" = "提交";
Expand Down Expand Up @@ -4247,6 +4248,7 @@
"The active repository changed. Inspect the original repository before retrying." = "当前仓库已更改。重试前请检查原仓库。";
"The address is invalid." = "地址无效。";
"The application closed before the debug terminal could start." = "调试终端启动前应用已关闭。";
"The branch changed while choosing a pull strategy. Review it and try again." = "选择拉取策略期间分支状态已变化,请检查后重试。";
"The branch could not be published" = "无法发布该分支";
"The branch now contains the completed plan. Its original history remains available through the recovery reference." = "操作计划已执行完成。仍可通过恢复引用查看分支的原始历史。";
"The breakdown needs Model call statistics (on by default). After turning it on, reconnect and send a message." = "分项需要开启“模型调用统计”(默认开启)。开启后请重新连接并发送消息。";
Expand Down Expand Up @@ -4749,6 +4751,7 @@
"UNFILED CONNECTIONS" = "未归档连接";
"URL" = "URL";
"Unable to create the Maven dependency plan." = "无法创建 Maven 依赖解析计划。";
"Unable to inspect the branch." = "无法检查当前分支。";
"Unable to parse Maven dependencies for this module." = "无法解析此模块的 Maven 依赖。";
"Unable to read settings" = "无法读取设置";
"Unable to resolve Maven dependencies." = "无法解析 Maven 依赖。";
Expand Down Expand Up @@ -5260,6 +5263,9 @@
"git.log.branchNameEmpty" = "请指定新分支的名称";
"git.log.branchNameHead" = "HEAD 是保留关键字";
"git.log.olderCommitsFailed" = "无法加载更早的提交,点击刷新历史";
"git.pullResult.dirty" = "拉取前请先提交或贮藏本地更改。";
"git.pullResult.inspectBranchFailed" = "无法检查当前分支。";
"git.pullResult.stateChanged" = "选择拉取策略期间分支状态已变化,请检查后重试。";
"git.rebasePlan.issue.emptyReword" = "每个 Reword 步骤都需要提交信息。";
"git.rebasePlan.issue.emptySquash" = "请输入 Squash 信息,或使用默认的合并信息。";
"git.rebasePlan.issue.invalidMessage" = "此计划中的提交信息无效。";
Expand Down
15 changes: 11 additions & 4 deletions macos/Sources/Lithe/Core/Rust/RustCoreBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1323,6 +1323,7 @@ struct RustCoreBridge: Sendable, IncrementalLanguageServerRuntimeCore {
let behind: Int
let diverged: Bool
let hasLocalChanges: Bool
let configuredStrategy: String?
}

struct GitOperationStatePayload: Decodable, Sendable {
Expand Down Expand Up @@ -2372,6 +2373,8 @@ struct RustCoreBridge: Sendable, IncrementalLanguageServerRuntimeCore {
/// Destination confirmed for a divergent upstream; omitted so routine
/// pushes keep their existing behaviour.
let pushTarget: String?
/// Complete local reference a guarded pull must still find checked out.
let expectedBranch: String?
}

private struct GitDiffRequest: Encodable {
Expand Down Expand Up @@ -3282,7 +3285,8 @@ struct RustCoreBridge: Sendable, IncrementalLanguageServerRuntimeCore {
amend: Bool = false,
force: Bool = false,
autoStash: Bool = false,
pushTarget: String? = nil
pushTarget: String? = nil,
expectedBranch: String? = nil
) -> GitCommandPayload? {
execute(
command: "git.write",
Expand All @@ -3304,7 +3308,8 @@ struct RustCoreBridge: Sendable, IncrementalLanguageServerRuntimeCore {
amend: amend,
force: force,
autoStash: autoStash,
pushTarget: pushTarget
pushTarget: pushTarget,
expectedBranch: expectedBranch
)
)
}
Expand Down Expand Up @@ -3381,7 +3386,8 @@ struct RustCoreBridge: Sendable, IncrementalLanguageServerRuntimeCore {
amend: Bool = false,
force: Bool = false,
autoStash: Bool = false,
pushTarget: String? = nil
pushTarget: String? = nil,
expectedBranch: String? = nil
) -> Result<GitCommandPayload, CoreCallError> {
executeResult(
command: "git.write",
Expand All @@ -3403,7 +3409,8 @@ struct RustCoreBridge: Sendable, IncrementalLanguageServerRuntimeCore {
amend: amend,
force: force,
autoStash: autoStash,
pushTarget: pushTarget
pushTarget: pushTarget,
expectedBranch: expectedBranch
)
)
}
Expand Down
17 changes: 12 additions & 5 deletions macos/Sources/Lithe/Core/Rust/RustGitOperations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ struct RustGitOperations: GitOperations, Sendable {
amend: Bool = false,
force: Bool = false,
autoStash: Bool = false,
pushTarget: String? = nil
pushTarget: String? = nil,
expectedBranch: String? = nil
) -> GitProcessResult? {
switch core.gitWriteResult(
at: rootURL,
Expand All @@ -118,7 +119,8 @@ struct RustGitOperations: GitOperations, Sendable {
amend: amend,
force: force,
autoStash: autoStash,
pushTarget: pushTarget
pushTarget: pushTarget,
expectedBranch: expectedBranch
) {
case .success(let response):
return makeProcessResult(response)
Expand Down Expand Up @@ -390,8 +392,12 @@ struct RustGitOperations: GitOperations, Sendable {
)
}

func updateCurrentBranch(at rootURL: URL, strategy: GitPullStrategy = .ffOnly) -> GitProcessResult? {
write(at: rootURL, operation: "pull", mode: strategy.rawValue)
func updateCurrentBranch(
at rootURL: URL,
strategy: GitPullStrategy,
expectedBranch: String?
) -> GitProcessResult? {
write(at: rootURL, operation: "pull", mode: strategy.rawValue, expectedBranch: expectedBranch)
}

/// Staged files still containing conflict markers.
Expand Down Expand Up @@ -435,7 +441,8 @@ struct RustGitOperations: GitOperations, Sendable {
ahead: payload.ahead,
behind: payload.behind,
diverged: payload.diverged,
hasLocalChanges: payload.hasLocalChanges
hasLocalChanges: payload.hasLocalChanges,
configuredStrategy: payload.configuredStrategy.flatMap(GitPullStrategy.init(rawValue:))
)
}

Expand Down
4 changes: 2 additions & 2 deletions macos/Sources/Lithe/Models/AppModel/AppModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1616,9 +1616,9 @@ final class AppModel: ObservableObject, Identifiable, UnsavedDocumentHandling {
await gitFeature.continueGitOperation()
}

func resolvePullStrategy(_ strategy: GitPullStrategy) async {
func resolvePullStrategy(_ strategy: GitPullStrategy, for request: GitPullStrategyRequest) async {
guard let gitFeature = await activateGitModule() else { return }
await gitFeature.resolvePullStrategy(strategy)
await gitFeature.resolvePullStrategy(strategy, for: request)
}

func cancelPullStrategy() {
Expand Down
2 changes: 1 addition & 1 deletion macos/Sources/Lithe/Views/Workbench/WorkbenchView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ struct WorkbenchView: View {
}
.sheet(item: $model.pendingPullStrategy) { request in
GitPullStrategyDialog(request: request) { strategy in
Task { await model.resolvePullStrategy(strategy) }
Task { await model.resolvePullStrategy(strategy, for: request) }
}
.onDisappear { model.cancelPullStrategy() }
}
Expand Down
Loading
Loading