Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
429a2da4
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
429a2da4
编写于
5月 25, 2018
作者:
P
Peng Lyu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove unused code.
上级
2c64d63d
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
1 addition
and
88 deletion
+1
-88
extensions/git-extended/src/common/file.ts
extensions/git-extended/src/common/file.ts
+1
-58
extensions/git-extended/src/models/file.ts
extensions/git-extended/src/models/file.ts
+0
-30
未找到文件。
extensions/git-extended/src/common/file.ts
浏览文件 @
429a2da4
...
...
@@ -3,14 +3,9 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
GitProcess
}
from
'
dugite
'
;
import
*
as
fs
from
'
fs
'
;
import
*
as
path
from
'
path
'
;
import
*
as
tmp
from
'
tmp
'
;
import
*
as
vscode
from
'
vscode
'
;
import
{
GitProcess
}
from
'
dugite
'
;
import
{
Repository
}
from
'
../models/repository
'
;
import
{
SlimFileChange
,
GitChangeType
,
fromStatus
}
from
'
../models/file
'
;
export
async
function
writeTmpFile
(
content
:
string
,
ext
:
string
):
Promise
<
string
>
{
return
new
Promise
<
string
>
((
resolve
,
reject
)
=>
{
...
...
@@ -30,32 +25,6 @@ export async function writeTmpFile(content: string, ext: string): Promise<string
});
}
export
async
function
getFile
(
commitSha1
:
string
,
localFilePath
:
string
):
Promise
<
string
>
{
const
rootDir
=
vscode
.
workspace
.
rootPath
;
return
new
Promise
<
string
>
((
resolve
,
reject
)
=>
{
if
(
commitSha1
===
undefined
)
{
resolve
(
'
fileUnavailable
'
);
return
;
}
let
ext
=
path
.
extname
(
localFilePath
);
tmp
.
file
({
postfix
:
ext
},
async
(
err
:
any
,
tmpFilePath
:
string
)
=>
{
if
(
err
)
{
reject
(
err
);
return
;
}
try
{
let
data
=
await
getFileContent
(
rootDir
,
commitSha1
,
localFilePath
);
fs
.
appendFileSync
(
tmpFilePath
,
data
);
resolve
(
tmpFilePath
);
}
catch
(
ex
)
{
console
.
log
(
ex
);
reject
(
ex
);
}
});
});
}
export
async
function
getFileContent
(
rootDir
:
string
,
commitSha
:
string
,
sourceFilePath
:
string
):
Promise
<
string
>
{
const
result
=
await
GitProcess
.
exec
([
'
show
'
,
...
...
@@ -71,29 +40,3 @@ export async function getFileContent(rootDir: string, commitSha: string, sourceF
throw
error
;
}
}
export
async
function
getChangedFiles
(
repository
:
Repository
,
sha
:
string
):
Promise
<
ReadonlyArray
<
SlimFileChange
>>
{
const
args
=
[
'
log
'
,
sha
,
'
--name-status
'
,
'
--format=format:
'
,
'
-z
'
,
'
-1
'
];
const
result
=
await
GitProcess
.
exec
(
args
,
repository
.
path
);
const
out
=
result
.
stdout
;
const
lines
=
out
.
split
(
'
\
0
'
);
lines
.
splice
(
-
1
,
1
);
const
files
:
SlimFileChange
[]
=
[];
for
(
let
i
=
0
;
i
<
lines
.
length
;
i
++
)
{
const
statusText
=
lines
[
i
];
const
status
=
fromStatus
(
statusText
);
let
originalPath
:
string
|
undefined
=
undefined
;
if
(
status
===
GitChangeType
.
RENAME
||
status
===
GitChangeType
.
COPY
)
{
originalPath
=
lines
[
++
i
];
}
const
path
=
lines
[
++
i
];
files
.
push
(
new
SlimFileChange
(
path
,
originalPath
,
status
,
null
));
}
return
files
;
}
\ No newline at end of file
extensions/git-extended/src/models/file.ts
浏览文件 @
429a2da4
...
...
@@ -16,36 +16,6 @@ export enum GitChangeType {
UNMERGED
}
export
function
fromStatus
(
status
:
string
):
GitChangeType
{
switch
(
status
)
{
case
'
A
'
:
return
GitChangeType
.
ADD
;
case
'
C
'
:
return
GitChangeType
.
COPY
;
case
'
D
'
:
return
GitChangeType
.
DELETE
;
case
'
M
'
:
return
GitChangeType
.
MODIFY
;
case
'
R
'
:
return
GitChangeType
.
RENAME
;
case
'
T
'
:
return
GitChangeType
.
TYPE
;
case
'
X
'
:
return
GitChangeType
.
UNKNOWN
;
case
'
U
'
:
return
GitChangeType
.
UNMERGED
;
}
if
(
status
.
match
(
/R
[
0-9
]
+/
))
{
return
GitChangeType
.
RENAME
;
}
if
(
status
.
match
(
/C
[
0-9
]
+/
))
{
return
GitChangeType
.
COPY
;
}
return
GitChangeType
.
MODIFY
;
}
export
class
SlimFileChange
{
public
originalContent
:
string
;
public
content
:
string
;
constructor
(
public
readonly
filePath
:
string
,
public
readonly
originalFilePath
:
string
,
public
readonly
status
:
GitChangeType
,
public
readonly
fileName
:
string
)
{
}
}
export
class
RichFileChange
{
public
blobUrl
:
string
;
constructor
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录