初步给项目、飞行器、容器页面添加了git拉取功能
This commit is contained in:
13
src/panels/services/GitService.ts
Normal file → Executable file
13
src/panels/services/GitService.ts
Normal file → Executable file
@@ -1,3 +1,4 @@
|
||||
// src/panels/services/GitService.ts
|
||||
import * as fs from 'fs';
|
||||
import git from 'isomorphic-git';
|
||||
import http from 'isomorphic-git/http/node';
|
||||
@@ -290,6 +291,10 @@ export class GitService {
|
||||
|
||||
/**
|
||||
* 构建文件树
|
||||
* 这里显式忽略:
|
||||
* - .git 目录
|
||||
* - .dcsp-data.json
|
||||
* - 其它以 . 开头的隐藏文件/目录
|
||||
*/
|
||||
static async buildFileTree(dir: string, relativePath: string = ''): Promise<GitFileTree[]> {
|
||||
try {
|
||||
@@ -297,9 +302,15 @@ export class GitService {
|
||||
const tree: GitFileTree[] = [];
|
||||
|
||||
for (const file of files) {
|
||||
if (file.startsWith('.') && file !== '.git') continue;
|
||||
// 1. 不要解析 .git
|
||||
if (file === '.git') continue;
|
||||
|
||||
// 2. 不要解析项目数据文件
|
||||
if (file === '.dcsp-data.json') continue;
|
||||
|
||||
// 3. 其它所有隐藏文件/目录统统忽略
|
||||
if (file.startsWith('.')) continue;
|
||||
|
||||
const filePath = path.join(dir, file);
|
||||
const stats = await fs.promises.stat(filePath);
|
||||
const currentRelativePath = path.join(relativePath, file);
|
||||
|
||||
Reference in New Issue
Block a user