Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
26b8508d
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,发现更多精彩内容 >>
提交
26b8508d
编写于
12月 13, 2017
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'git-submodules' of
https://github.com/petkahl/vscode
into petkahl-git-submodules
上级
57c37e0c
124b9a40
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
70 addition
and
2 deletion
+70
-2
extensions/git/src/commands.ts
extensions/git/src/commands.ts
+8
-0
extensions/git/src/git.ts
extensions/git/src/git.ts
+17
-0
extensions/git/src/model.ts
extensions/git/src/model.ts
+19
-1
extensions/git/src/repository.ts
extensions/git/src/repository.ts
+26
-1
未找到文件。
extensions/git/src/commands.ts
浏览文件 @
26b8508d
...
...
@@ -13,6 +13,7 @@ import { toGitUri, fromGitUri } from './uri';
import
{
grep
,
eventToPromise
,
isDescendant
}
from
'
./util
'
;
import
{
applyLineChanges
,
intersectDiffWithRange
,
toLineRanges
,
invertLineChange
}
from
'
./staging
'
;
import
*
as
path
from
'
path
'
;
import
{
lstat
,
Stats
}
from
'
fs
'
;
import
*
as
os
from
'
os
'
;
import
TelemetryReporter
from
'
vscode-extension-telemetry
'
;
import
*
as
nls
from
'
vscode-nls
'
;
...
...
@@ -168,8 +169,15 @@ export class CommandCenter {
}
private
async
_openResource
(
resource
:
Resource
,
preview
?:
boolean
,
preserveFocus
?:
boolean
,
preserveSelection
?:
boolean
):
Promise
<
void
>
{
const
stat
=
await
new
Promise
<
Stats
>
((
c
,
e
)
=>
lstat
(
resource
.
resourceUri
.
fsPath
,
(
err
,
stat
)
=>
err
?
e
(
err
)
:
c
(
stat
)));
if
(
stat
.
isDirectory
())
{
return
;
}
const
left
=
await
this
.
getLeftResource
(
resource
);
const
right
=
await
this
.
getRightResource
(
resource
);
const
title
=
this
.
getTitle
(
resource
);
if
(
!
right
)
{
...
...
extensions/git/src/git.ts
浏览文件 @
26b8508d
...
...
@@ -34,6 +34,11 @@ export interface Remote {
url
:
string
;
}
export
interface
ISubmodule
{
Root
:
string
;
Status
:
string
;
}
export
interface
Stash
{
index
:
number
;
description
:
string
;
...
...
@@ -1108,6 +1113,18 @@ export class Repository {
return
uniqBy
(
rawRemotes
,
remote
=>
remote
.
name
);
}
async
getSubmodules
():
Promise
<
ISubmodule
[]
>
{
const
result
=
await
this
.
run
([
'
submodule
'
,
'
status
'
]);
const
regex
=
/^
([
\+\-
U
])\w
*
(\w
*
)(
\(
.*
\))?
/
;
const
submodules
=
result
.
stdout
.
split
(
'
\n
'
)
.
filter
(
b
=>
!!
b
)
.
map
(
line
=>
regex
.
exec
(
line
))
.
filter
(
g
=>
!!
g
)
.
map
((
groups
:
RegExpExecArray
)
=>
({
Root
:
path
.
join
(
this
.
repositoryRoot
,
groups
[
2
]),
Status
:
groups
[
1
]
}));
//this._git.onOutput.emit('log', submodules);
return
submodules
;
}
async
getBranch
(
name
:
string
):
Promise
<
Branch
>
{
if
(
name
===
'
HEAD
'
)
{
return
this
.
getHEAD
();
...
...
extensions/git/src/model.ts
浏览文件 @
26b8508d
...
...
@@ -173,6 +173,23 @@ export class Model {
});
}
private
async
scanForSubmodules
(
repository
:
Repository
):
Promise
<
void
>
{
const
submodules
=
await
repository
.
getSubmodules
();
//console.log(`Opening ${submoduleRoot} as git repository`);
for
(
const
submodule
of
submodules
)
{
try
{
// We can't call tryOpenRepository, because a submodule is going to be under an open repository, so will fail.
const
subRepository
=
new
Repository
(
this
.
git
.
open
((
submodule
.
Root
)),
this
.
globalState
);
this
.
open
(
subRepository
);
}
catch
(
err
)
{
if
(
err
.
gitErrorCode
===
GitErrorCodes
.
NotAGitRepository
)
{
return
;
}
}
}
}
@
sequentialize
async
tryOpenRepository
(
path
:
string
):
Promise
<
void
>
{
if
(
this
.
getRepository
(
path
))
{
...
...
@@ -227,6 +244,7 @@ export class Model {
const
openRepository
=
{
repository
,
dispose
};
this
.
openRepositories
.
push
(
openRepository
);
this
.
_onDidOpenRepository
.
fire
(
repository
);
this
.
scanForSubmodules
(
repository
);
}
close
(
repository
:
Repository
):
void
{
...
...
@@ -281,7 +299,7 @@ export class Model {
if
(
hint
instanceof
Uri
)
{
const
resourcePath
=
hint
.
fsPath
;
for
(
const
liveRepository
of
this
.
openRepositories
)
{
for
(
const
liveRepository
of
this
.
openRepositories
.
sort
((
a
,
b
)
=>
b
.
repository
.
root
.
length
-
a
.
repository
.
root
.
length
)
)
{
const
relativePath
=
path
.
relative
(
liveRepository
.
repository
.
root
,
resourcePath
);
if
(
isDescendant
(
liveRepository
.
repository
.
root
,
resourcePath
))
{
...
...
extensions/git/src/repository.ts
浏览文件 @
26b8508d
...
...
@@ -6,7 +6,7 @@
'
use strict
'
;
import
{
Uri
,
Command
,
EventEmitter
,
Event
,
scm
,
SourceControl
,
SourceControlInputBox
,
SourceControlResourceGroup
,
SourceControlResourceState
,
SourceControlResourceDecorations
,
Disposable
,
ProgressLocation
,
window
,
workspace
,
WorkspaceEdit
,
ThemeColor
,
DecorationData
,
Memento
}
from
'
vscode
'
;
import
{
Repository
as
BaseRepository
,
Ref
,
Branch
,
Remote
,
Commit
,
GitErrorCodes
,
Stash
,
RefType
,
GitError
}
from
'
./git
'
;
import
{
Repository
as
BaseRepository
,
Ref
,
Branch
,
Remote
,
Commit
,
GitErrorCodes
,
Stash
,
RefType
,
GitError
,
ISubmodule
}
from
'
./git
'
;
import
{
anyEvent
,
filterEvent
,
eventToPromise
,
dispose
,
find
,
isDescendant
,
IDisposable
,
onceEvent
,
EmptyDisposable
,
debounceEvent
}
from
'
./util
'
;
import
{
memoize
,
throttle
,
debounce
}
from
'
./decorators
'
;
import
{
toGitUri
}
from
'
./uri
'
;
...
...
@@ -420,6 +420,18 @@ class ProgressManager {
}
}
export
enum
SubmoduleStatus
{
Uninitialized
,
Current
,
Conflict
,
Modified
}
export
interface
Submodule
{
Root
:
string
;
Status
:
SubmoduleStatus
;
}
export
class
Repository
implements
Disposable
{
private
_onDidChangeRepository
=
new
EventEmitter
<
Uri
>
();
...
...
@@ -757,6 +769,19 @@ export class Repository implements Disposable {
return
this
.
run
(
Operation
.
Show
,
()
=>
this
.
repository
.
detectObjectType
(
object
));
}
async
getSubmodules
():
Promise
<
Submodule
[]
>
{
const
submodules
:
ISubmodule
[]
=
await
this
.
repository
.
getSubmodules
();
return
submodules
.
map
(
isub
=>
{
var
status
=
SubmoduleStatus
.
Current
;
switch
(
isub
.
Status
)
{
case
'
-
'
:
{
status
=
SubmoduleStatus
.
Uninitialized
;
break
;
}
case
'
+
'
:
{
status
=
SubmoduleStatus
.
Modified
;
break
;
}
case
'
U
'
:
{
status
=
SubmoduleStatus
.
Conflict
;
break
;
}
}
return
{
Root
:
isub
.
Root
,
Status
:
status
};
});
}
async
getStashes
():
Promise
<
Stash
[]
>
{
return
await
this
.
repository
.
getStashes
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录