mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-13 04:34:21 -10:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4522b9a5e1 |
No files matched your search
@@ -49,6 +49,7 @@ import { allRepos, runRemote } from "./ops";
|
||||
import { showPushDialog, showUpdateDialog, type PushTarget, type UpdateTarget } from "./remoteUi";
|
||||
import { comparePathsWithRevision, showDirectoryWorkingDiff } from "./comparePaths";
|
||||
import { showCloneDialog } from "./clone";
|
||||
import { createRepository } from "./createRepository";
|
||||
import {
|
||||
showManageRemotes,
|
||||
showMergeDialog,
|
||||
@@ -246,6 +247,15 @@ export function registerVcsActions(): () => void {
|
||||
keyWhen: IN_COMMIT_WINDOW,
|
||||
run: () => useCommit.setState((s) => ({ historyTick: s.historyTick + 1 })),
|
||||
},
|
||||
{
|
||||
id: "vcs.createRepository",
|
||||
title: "Create Git Repository…",
|
||||
category: "Git",
|
||||
icon: "branch",
|
||||
when: "projectOpen && projectLocal",
|
||||
keywords: ["init", "git", "enable version control"],
|
||||
run: () => createRepository(),
|
||||
},
|
||||
{
|
||||
id: "vcs.clone",
|
||||
title: "Get from Version Control…",
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/** VCS › Create Git Repository…: `git init` in a folder chosen under the project. */
|
||||
import { open } from "@/platform/dialog";
|
||||
import { tx } from "@/platform/i18n";
|
||||
import { call, commands } from "@/platform/ipc";
|
||||
import { useProject } from "@/platform/project";
|
||||
import { notifications } from "@/workbench/contributions";
|
||||
import { discoverRoots } from "./store";
|
||||
|
||||
export async function createRepository() {
|
||||
const root = useProject.getState().project?.root;
|
||||
const dir = await open({ title: tx("Select Directory for Git Init"), directory: true, defaultPath: root });
|
||||
if (typeof dir !== "string") return;
|
||||
try {
|
||||
await call(commands.vcsInit(dir));
|
||||
} catch (e) {
|
||||
notifications().notify({
|
||||
group: "vcs",
|
||||
level: "error",
|
||||
title: tx("Couldn't create Git repository"),
|
||||
body: String((e as Error)?.message ?? e),
|
||||
});
|
||||
return;
|
||||
}
|
||||
notifications().notify({ group: "vcs", level: "info", title: tx`Created Git repository in ${dir}` });
|
||||
await discoverRoots();
|
||||
}
|
||||
@@ -266,7 +266,7 @@ export function statusOf(path: string): FileStatus | undefined {
|
||||
}
|
||||
|
||||
/** Repositories found below a project that is not itself under git (scanned in the background). */
|
||||
async function discoverRoots() {
|
||||
export async function discoverRoots() {
|
||||
const root = useVcs.getState().root;
|
||||
if (!root || !isTauri()) return;
|
||||
const roots = await call(commands.vcsRoots()).catch(() => []);
|
||||
|
||||
@@ -1510,5 +1510,9 @@
|
||||
"{name} (group)": "{name} (group)",
|
||||
"Servers in group": "Servers in group",
|
||||
"Upload to… on this group uploads the files to each of its servers in turn.": "Upload to… on this group uploads the files to each of its servers in turn.",
|
||||
"Server Group": "Server Group"
|
||||
"Server Group": "Server Group",
|
||||
"Create Git Repository…": "Create Git Repository…",
|
||||
"Select Directory for Git Init": "Select Directory for Git Init",
|
||||
"Couldn't create Git repository": "Couldn't create Git repository",
|
||||
"Created Git repository in {dir}": "Created Git repository in {dir}"
|
||||
}
|
||||
@@ -7911,5 +7911,9 @@
|
||||
"{name} (group)": "{name}(分组)",
|
||||
"Servers in group": "组内服务器",
|
||||
"Upload to… on this group uploads the files to each of its servers in turn.": "对此分组执行“上传到…”时,会依次上传到组内的每台服务器。",
|
||||
"Server Group": "服务器分组"
|
||||
"Server Group": "服务器分组",
|
||||
"Create Git Repository…": "创建 Git 仓库…",
|
||||
"Select Directory for Git Init": "选择要执行 Git Init 的目录",
|
||||
"Couldn't create Git repository": "无法创建 Git 仓库",
|
||||
"Created Git repository in {dir}": "已在 {dir} 创建 Git 仓库"
|
||||
}
|
||||
@@ -95,7 +95,7 @@ function ProjectButton() {
|
||||
);
|
||||
}
|
||||
|
||||
const VCS_FALLBACK_ACTIONS = ["vcs.clone", "vcs.localHistory", "vcs.showLog"];
|
||||
const VCS_FALLBACK_ACTIONS = ["vcs.createRepository", "vcs.clone", "vcs.localHistory", "vcs.showLog"];
|
||||
|
||||
/** "Version Control ▾" shown while no VCS widget is contributed (project without a repository). */
|
||||
function VcsFallback() {
|
||||
|
||||
Reference in new issue
Block a user