1
This commit is contained in:
1 parent
f78f4aeb4a
commit
85fe316cf1
3 files changed
+163
No files matched your search
@@ -1101,5 +1101,60 @@
|
|||||||
"type": "String"
|
"type": "String"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"gitNotInstalled": "Git Not Found",
|
||||||
|
"gitNotInstalledDesc": "Git command-line tool was not found on your system. Please install git in your terminal or Linux container (e.g. apt update && apt install -y git).",
|
||||||
|
"gitNeedInstall": "Git Installation Required",
|
||||||
|
"gitInstallAction": "Install Git",
|
||||||
|
"gitInstallingProgress": "Installing Git...",
|
||||||
|
"gitInstallSuccess": "Git installed successfully",
|
||||||
|
"gitInstallFailed": "Failed to install Git: {error}",
|
||||||
|
"@gitInstallFailed": {
|
||||||
|
"placeholders": {
|
||||||
|
"error": {
|
||||||
|
"type": "String"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"gitNoRepoFound": "No Git Repository",
|
||||||
|
"gitNoRepoDesc": "Initialize a Git repository to start version control, branch management, and tracking code changes.",
|
||||||
|
"gitInitRepo": "Initialize Repository",
|
||||||
|
"gitInitializing": "Initializing Git repository...",
|
||||||
|
"gitInitSuccess": "Git repository initialized successfully",
|
||||||
|
"gitInitFailed": "Failed to initialize Git repository: {error}",
|
||||||
|
"@gitInitFailed": {
|
||||||
|
"placeholders": {
|
||||||
|
"error": {
|
||||||
|
"type": "String"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"gitRepository": "Repository",
|
||||||
|
"gitCurrentBranch": "Branch: {branch}",
|
||||||
|
"@gitCurrentBranch": {
|
||||||
|
"placeholders": {
|
||||||
|
"branch": {
|
||||||
|
"type": "String"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"gitSwitchRepo": "Switch Repository",
|
||||||
|
"gitRefresh": "Refresh Git",
|
||||||
|
"gitChanges": "Changes",
|
||||||
|
"gitStagedChanges": "Staged Changes",
|
||||||
|
"gitNoChanges": "No changes detected",
|
||||||
|
"gitStatusUntracked": "Untracked",
|
||||||
|
"gitStatusModified": "Modified",
|
||||||
|
"gitStatusAdded": "Added",
|
||||||
|
"gitStatusDeleted": "Deleted",
|
||||||
|
"gitStatusRenamed": "Renamed",
|
||||||
|
"gitStatusConflict": "Conflict",
|
||||||
|
"gitMultipleReposDetected": "Multiple Repositories ({count})",
|
||||||
|
"@gitMultipleReposDetected": {
|
||||||
|
"placeholders": {
|
||||||
|
"count": {
|
||||||
|
"type": "int"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'package:code_editor/l10n/app_localizations.dart';
|
import 'package:code_editor/l10n/app_localizations.dart';
|
||||||
import 'package:code_editor/providers/distro_provider.dart';
|
import 'package:code_editor/providers/distro_provider.dart';
|
||||||
|
import 'package:code_editor/providers/git_provider.dart';
|
||||||
import 'package:code_editor/providers/notice_center.dart';
|
import 'package:code_editor/providers/notice_center.dart';
|
||||||
import 'package:code_editor/providers/project_provider.dart';
|
import 'package:code_editor/providers/project_provider.dart';
|
||||||
import 'package:code_editor/providers/run_provider.dart';
|
import 'package:code_editor/providers/run_provider.dart';
|
||||||
@@ -51,6 +52,11 @@ class MyApp extends StatelessWidget {
|
|||||||
update: (_, project, search) =>
|
update: (_, project, search) =>
|
||||||
(search ?? SearchProvider())..bindRootPath(project.rootPath),
|
(search ?? SearchProvider())..bindRootPath(project.rootPath),
|
||||||
),
|
),
|
||||||
|
ChangeNotifierProxyProvider<ProjectProvider, GitProvider>(
|
||||||
|
create: (_) => GitProvider(),
|
||||||
|
update: (_, project, git) =>
|
||||||
|
(git ?? GitProvider())..bindRootPath(project.rootPath),
|
||||||
|
),
|
||||||
ChangeNotifierProvider(create: (_) => TerminalProvider()),
|
ChangeNotifierProvider(create: (_) => TerminalProvider()),
|
||||||
ChangeNotifierProvider(
|
ChangeNotifierProvider(
|
||||||
create: (_) {
|
create: (_) {
|
||||||
|
|||||||
@@ -0,0 +1,102 @@
|
|||||||
|
import 'package:path/path.dart' as p;
|
||||||
|
|
||||||
|
/// Git 文件状态类别
|
||||||
|
enum GitFileStatusType {
|
||||||
|
untracked, // 未跟踪 (??)
|
||||||
|
modified, // 已修改 ( M / M )
|
||||||
|
added, // 新增 (A )
|
||||||
|
deleted, // 已删除 ( D / D )
|
||||||
|
renamed, // 重命名 (R )
|
||||||
|
copied, // 复制 (C )
|
||||||
|
typeChange,// 类型变更 (T )
|
||||||
|
unmerged, // 冲突未合并 (UU / AA / DD 等)
|
||||||
|
ignored, // 忽略 (!!)
|
||||||
|
unknown, // 未知
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Git 文件变更条目
|
||||||
|
class GitFileStatus {
|
||||||
|
final String path;
|
||||||
|
final String relativePath;
|
||||||
|
final GitFileStatusType statusType;
|
||||||
|
final bool isStaged;
|
||||||
|
final String? originalPath; // 用于重命名/复制的源路径
|
||||||
|
|
||||||
|
const GitFileStatus({
|
||||||
|
required this.path,
|
||||||
|
required this.relativePath,
|
||||||
|
required this.statusType,
|
||||||
|
this.isStaged = false,
|
||||||
|
this.originalPath,
|
||||||
|
});
|
||||||
|
|
||||||
|
String get fileName => p.basename(relativePath);
|
||||||
|
|
||||||
|
String get directoryPath {
|
||||||
|
final dir = p.dirname(relativePath);
|
||||||
|
return dir == '.' ? '' : dir;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Git 仓库信息(支持根仓库及子模块/嵌套仓库)
|
||||||
|
class GitRepositoryInfo {
|
||||||
|
final String rootPath;
|
||||||
|
final String name;
|
||||||
|
final bool isRoot;
|
||||||
|
final String? currentBranch;
|
||||||
|
|
||||||
|
const GitRepositoryInfo({
|
||||||
|
required this.rootPath,
|
||||||
|
required this.name,
|
||||||
|
this.isRoot = false,
|
||||||
|
this.currentBranch,
|
||||||
|
});
|
||||||
|
|
||||||
|
GitRepositoryInfo copyWith({
|
||||||
|
String? rootPath,
|
||||||
|
String? name,
|
||||||
|
bool? isRoot,
|
||||||
|
String? currentBranch,
|
||||||
|
}) {
|
||||||
|
return GitRepositoryInfo(
|
||||||
|
rootPath: rootPath ?? this.rootPath,
|
||||||
|
name: name ?? this.name,
|
||||||
|
isRoot: isRoot ?? this.isRoot,
|
||||||
|
currentBranch: currentBranch ?? this.currentBranch,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) =>
|
||||||
|
identical(this, other) ||
|
||||||
|
other is GitRepositoryInfo &&
|
||||||
|
runtimeType == other.runtimeType &&
|
||||||
|
rootPath == other.rootPath;
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => rootPath.hashCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Git 命令行执行结果
|
||||||
|
class GitCommandResult {
|
||||||
|
final bool success;
|
||||||
|
final int exitCode;
|
||||||
|
final String stdout;
|
||||||
|
final String stderr;
|
||||||
|
|
||||||
|
const GitCommandResult({
|
||||||
|
required this.success,
|
||||||
|
required this.exitCode,
|
||||||
|
required this.stdout,
|
||||||
|
required this.stderr,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory GitCommandResult.error(String message, {int exitCode = -1}) {
|
||||||
|
return GitCommandResult(
|
||||||
|
success: false,
|
||||||
|
exitCode: exitCode,
|
||||||
|
stdout: '',
|
||||||
|
stderr: message,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user