Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
acb83d00
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,发现更多精彩内容 >>
提交
acb83d00
编写于
8月 15, 2017
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove Resource from git model method interfaces
上级
b9eb8bae
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
49 addition
and
21 deletion
+49
-21
extensions/git/src/commands.ts
extensions/git/src/commands.ts
+18
-12
extensions/git/src/model.ts
extensions/git/src/model.ts
+16
-9
extensions/git/src/util.ts
extensions/git/src/util.ts
+15
-0
未找到文件。
extensions/git/src/commands.ts
浏览文件 @
acb83d00
...
...
@@ -145,9 +145,9 @@ export class CommandCenter {
});
}
private
groupByModel
(
resources
:
Resource
[]):
[
Model
|
undefined
,
Resource
[]][]
{
private
groupByModel
(
resources
:
Uri
[]):
[
Model
|
undefined
,
Uri
[]][]
{
return
resources
.
reduce
((
result
,
resource
)
=>
{
const
model
=
this
.
modelRegistry
.
getModel
(
resource
.
resourceUri
);
const
model
=
this
.
modelRegistry
.
getModel
(
resource
);
const
pair
=
result
.
filter
(
p
=>
p
[
0
]
===
model
)[
0
];
if
(
pair
)
{
...
...
@@ -157,7 +157,7 @@ export class CommandCenter {
}
return
result
;
},
[]
as
[
Model
|
undefined
,
Resource
[]][]);
},
[]
as
[
Model
|
undefined
,
Uri
[]][]);
}
@
command
(
'
git.refresh
'
,
{
model
:
true
})
...
...
@@ -442,16 +442,19 @@ export class CommandCenter {
resourceStates
=
[
resource
];
}
const
r
esources
=
resourceStates
const
scmR
esources
=
resourceStates
.
filter
(
s
=>
s
instanceof
Resource
&&
(
s
.
resourceGroup
instanceof
WorkingTreeGroup
||
s
.
resourceGroup
instanceof
MergeGroup
))
as
Resource
[];
if
(
!
r
esources
.
length
)
{
if
(
!
scmR
esources
.
length
)
{
return
;
}
await
Promise
.
all
(
this
.
groupByModel
(
resources
).
map
(
async
([
model
,
resources
])
=>
{
const
resources
=
scmResources
.
map
(
r
=>
r
.
resourceUri
);
const
resourcesByModel
=
this
.
groupByModel
(
resources
);
await
Promise
.
all
(
resourcesByModel
.
map
(
async
([
model
,
resources
])
=>
{
if
(
!
model
)
{
return
;
return
;
// TODO@joao
}
await
model
.
add
(...
resources
);
...
...
@@ -553,13 +556,15 @@ export class CommandCenter {
resourceStates
=
[
resource
];
}
const
r
esources
=
resourceStates
const
scmR
esources
=
resourceStates
.
filter
(
s
=>
s
instanceof
Resource
&&
s
.
resourceGroup
instanceof
IndexGroup
)
as
Resource
[];
if
(
!
r
esources
.
length
)
{
if
(
!
scmR
esources
.
length
)
{
return
;
}
const
resources
=
scmResources
.
map
(
r
=>
r
.
resourceUri
);
return
await
model
.
revertFiles
(...
resources
);
}
...
...
@@ -620,14 +625,15 @@ export class CommandCenter {
}
const
resources
=
resourceStates
.
filter
(
s
=>
s
instanceof
Resource
&&
s
.
resourceGroup
instanceof
WorkingTreeGroup
)
as
Resource
[];
.
filter
(
s
=>
s
instanceof
Resource
&&
s
.
resourceGroup
instanceof
WorkingTreeGroup
)
.
map
(
r
=>
r
.
resourceUri
);
if
(
!
resources
.
length
)
{
return
;
}
const
message
=
resources
.
length
===
1
?
localize
(
'
confirm discard
'
,
"
Are you sure you want to discard changes in {0}?
"
,
path
.
basename
(
resources
[
0
].
resourceUri
.
fsPath
))
?
localize
(
'
confirm discard
'
,
"
Are you sure you want to discard changes in {0}?
"
,
path
.
basename
(
resources
[
0
].
fsPath
))
:
localize
(
'
confirm discard multiple
'
,
"
Are you sure you want to discard changes in {0} files?
"
,
resources
.
length
);
const
yes
=
localize
(
'
discard
'
,
"
Discard Changes
"
);
...
...
@@ -650,7 +656,7 @@ export class CommandCenter {
return
;
}
await
model
.
clean
(...
model
.
workingTreeGroup
.
resources
);
await
model
.
clean
(...
model
.
workingTreeGroup
.
resources
.
map
(
r
=>
r
.
resourceUri
)
);
}
private
async
smartCommit
(
...
...
extensions/git/src/model.ts
浏览文件 @
acb83d00
...
...
@@ -7,7 +7,7 @@
import
{
Uri
,
Command
,
EventEmitter
,
Event
,
SourceControlResourceState
,
SourceControlResourceDecorations
,
Disposable
,
ProgressLocation
,
window
,
workspace
,
WorkspaceEdit
}
from
'
vscode
'
;
import
{
Git
,
Repository
,
Ref
,
Branch
,
Remote
,
Commit
,
GitErrorCodes
}
from
'
./git
'
;
import
{
anyEvent
,
eventToPromise
,
filterEvent
,
EmptyDisposable
,
combinedDisposable
,
dispose
}
from
'
./util
'
;
import
{
anyEvent
,
eventToPromise
,
filterEvent
,
EmptyDisposable
,
combinedDisposable
,
dispose
,
find
}
from
'
./util
'
;
import
{
memoize
,
throttle
,
debounce
}
from
'
./decorators
'
;
import
*
as
path
from
'
path
'
;
import
*
as
nls
from
'
vscode-nls
'
;
...
...
@@ -397,8 +397,8 @@ export class Model implements Disposable {
await
this
.
run
(
Operation
.
Status
);
}
async
add
(...
resources
:
Resource
[]):
Promise
<
void
>
{
await
this
.
run
(
Operation
.
Add
,
()
=>
this
.
repository
.
add
(
resources
.
map
(
r
=>
r
.
resourceUri
.
fsPath
)));
async
add
(...
resources
:
Uri
[]):
Promise
<
void
>
{
await
this
.
run
(
Operation
.
Add
,
()
=>
this
.
repository
.
add
(
resources
.
map
(
r
=>
r
.
fsPath
)));
}
async
stage
(
uri
:
Uri
,
contents
:
string
):
Promise
<
void
>
{
...
...
@@ -406,8 +406,8 @@ export class Model implements Disposable {
await
this
.
run
(
Operation
.
Stage
,
()
=>
this
.
repository
.
stage
(
relativePath
,
contents
));
}
async
revertFiles
(...
resources
:
Resource
[]):
Promise
<
void
>
{
await
this
.
run
(
Operation
.
RevertFiles
,
()
=>
this
.
repository
.
revertFiles
(
'
HEAD
'
,
resources
.
map
(
r
=>
r
.
resourceUri
.
fsPath
)));
async
revertFiles
(...
resources
:
Uri
[]):
Promise
<
void
>
{
await
this
.
run
(
Operation
.
RevertFiles
,
()
=>
this
.
repository
.
revertFiles
(
'
HEAD
'
,
resources
.
map
(
r
=>
r
.
fsPath
)));
}
async
commit
(
message
:
string
,
opts
:
CommitOptions
=
Object
.
create
(
null
)):
Promise
<
void
>
{
...
...
@@ -420,20 +420,27 @@ export class Model implements Disposable {
});
}
async
clean
(...
resources
:
Resource
[]):
Promise
<
void
>
{
async
clean
(...
resources
:
Uri
[]):
Promise
<
void
>
{
await
this
.
run
(
Operation
.
Clean
,
async
()
=>
{
const
toClean
:
string
[]
=
[];
const
toCheckout
:
string
[]
=
[];
resources
.
forEach
(
r
=>
{
switch
(
r
.
type
)
{
const
raw
=
r
.
toString
();
const
scmResource
=
find
(
this
.
workingTreeGroup
.
resources
,
sr
=>
sr
.
resourceUri
.
toString
()
===
raw
);
if
(
!
scmResource
)
{
return
;
}
switch
(
scmResource
.
type
)
{
case
Status
.
UNTRACKED
:
case
Status
.
IGNORED
:
toClean
.
push
(
r
.
resourceUri
.
fsPath
);
toClean
.
push
(
r
.
fsPath
);
break
;
default
:
toCheckout
.
push
(
r
.
resourceUri
.
fsPath
);
toCheckout
.
push
(
r
.
fsPath
);
break
;
}
});
...
...
extensions/git/src/util.ts
浏览文件 @
acb83d00
...
...
@@ -162,4 +162,19 @@ export function uniqueFilter<T>(keyFn: (t: T) => string): (t: T) => boolean {
seen
[
key
]
=
true
;
return
true
;
};
}
export
function
find
<
T
>
(
array
:
T
[],
fn
:
(
t
:
T
)
=>
boolean
):
T
|
undefined
{
let
result
:
T
|
undefined
=
undefined
;
array
.
some
(
e
=>
{
if
(
fn
(
e
))
{
result
=
e
;
return
true
;
}
return
false
;
});
return
result
;
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录