Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
66c24011
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,发现更多精彩内容 >>
提交
66c24011
编写于
2月 20, 2017
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
git: commit template
上级
77f0e953
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
11 addition
and
119 deletion
+11
-119
extensions/git/src/commands.ts
extensions/git/src/commands.ts
+2
-2
extensions/git/src/commit.ts
extensions/git/src/commit.ts
+0
-112
extensions/git/src/main.ts
extensions/git/src/main.ts
+3
-4
extensions/git/src/model.ts
extensions/git/src/model.ts
+6
-1
未找到文件。
extensions/git/src/commands.ts
浏览文件 @
66c24011
...
...
@@ -453,7 +453,7 @@ export class CommandCenter {
const
didCommit
=
await
this
.
smartCommit
(
getCommitMessage
,
opts
);
if
(
message
&&
didCommit
)
{
scm
.
inputBox
.
value
=
''
;
scm
.
inputBox
.
value
=
await
this
.
model
.
getCommitTemplate
()
;
}
}
...
...
@@ -467,7 +467,7 @@ export class CommandCenter {
const
didCommit
=
await
this
.
smartCommit
(
async
()
=>
scm
.
inputBox
.
value
);
if
(
didCommit
)
{
scm
.
inputBox
.
value
=
''
;
scm
.
inputBox
.
value
=
await
this
.
model
.
getCommitTemplate
()
;
}
}
...
...
extensions/git/src/commit.ts
已删除
100644 → 0
浏览文件 @
77f0e953
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
workspace
,
window
,
languages
,
Disposable
,
Uri
,
HoverProvider
,
Hover
,
TextEditor
,
Position
,
TextDocument
,
Range
,
TextEditorDecorationType
,
WorkspaceEdit
}
from
'
vscode
'
;
import
{
filterEvent
}
from
'
./util
'
;
import
*
as
nls
from
'
vscode-nls
'
;
const
localize
=
nls
.
loadMessageBundle
();
const
scmInputUri
=
Uri
.
parse
(
'
scm:input
'
);
function
isSCMInput
(
uri
:
Uri
)
{
return
uri
.
toString
()
===
scmInputUri
.
toString
();
}
interface
Diagnostic
{
range
:
Range
;
message
:
string
;
}
// TODO@Joao: hover disappears if editor is scrolled
export
class
CommitController
implements
HoverProvider
{
private
visibleTextEditorsDisposable
:
Disposable
;
private
editor
:
TextEditor
;
private
diagnostics
:
Diagnostic
[]
=
[];
private
decorationType
:
TextEditorDecorationType
;
private
disposables
:
Disposable
[]
=
[];
get
message
():
string
|
undefined
{
if
(
!
this
.
editor
)
{
return
;
}
return
this
.
editor
.
document
.
getText
();
}
set
message
(
message
:
string
|
undefined
)
{
if
(
!
this
.
editor
||
message
===
undefined
)
{
return
;
}
const
document
=
this
.
editor
.
document
;
const
start
=
document
.
lineAt
(
0
).
range
.
start
;
const
end
=
document
.
lineAt
(
document
.
lineCount
-
1
).
range
.
end
;
const
range
=
new
Range
(
start
,
end
);
const
edit
=
new
WorkspaceEdit
();
edit
.
replace
(
scmInputUri
,
range
,
message
);
workspace
.
applyEdit
(
edit
);
}
constructor
()
{
this
.
visibleTextEditorsDisposable
=
window
.
onDidChangeVisibleTextEditors
(
this
.
onVisibleTextEditors
,
this
);
this
.
onVisibleTextEditors
(
window
.
visibleTextEditors
);
this
.
decorationType
=
window
.
createTextEditorDecorationType
({
isWholeLine
:
true
,
color
:
'
rgb(228, 157, 43)
'
,
dark
:
{
color
:
'
rgb(220, 211, 71)
'
}
});
}
private
onVisibleTextEditors
(
editors
:
TextEditor
[]):
void
{
const
[
editor
]
=
editors
.
filter
(
e
=>
isSCMInput
(
e
.
document
.
uri
));
if
(
!
editor
)
{
return
;
}
this
.
visibleTextEditorsDisposable
.
dispose
();
this
.
editor
=
editor
;
const
onDidChange
=
filterEvent
(
workspace
.
onDidChangeTextDocument
,
e
=>
e
.
document
&&
isSCMInput
(
e
.
document
.
uri
));
onDidChange
(
this
.
update
,
this
,
this
.
disposables
);
workspace
.
onDidChangeConfiguration
(
this
.
update
,
this
,
this
.
disposables
);
languages
.
registerHoverProvider
({
scheme
:
'
scm
'
},
this
);
}
private
update
():
void
{
this
.
diagnostics
=
[];
const
range
=
this
.
editor
.
document
.
lineAt
(
0
).
range
;
const
length
=
range
.
end
.
character
-
range
.
start
.
character
;
if
(
workspace
.
getConfiguration
(
'
git
'
).
get
<
boolean
>
(
'
enableLongCommitWarning
'
)
&&
length
>
80
)
{
const
message
=
localize
(
'
too long
'
,
"
You should keep the first line under 50 characters.
\n\n
You can use more lines for extra information.
"
);
this
.
diagnostics
.
push
({
range
,
message
});
}
this
.
editor
.
setDecorations
(
this
.
decorationType
,
this
.
diagnostics
.
map
(
d
=>
d
.
range
));
}
provideHover
(
document
:
TextDocument
,
position
:
Position
):
Hover
|
undefined
{
const
[
decoration
]
=
this
.
diagnostics
.
filter
(
d
=>
d
.
range
.
contains
(
position
));
if
(
!
decoration
)
{
return
;
}
return
new
Hover
(
decoration
.
message
,
decoration
.
range
);
}
dispose
():
void
{
this
.
disposables
.
forEach
(
d
=>
d
.
dispose
());
}
}
extensions/git/src/main.ts
浏览文件 @
66c24011
...
...
@@ -5,7 +5,7 @@
'
use strict
'
;
import
{
ExtensionContext
,
workspace
,
window
,
Disposable
,
commands
,
Uri
}
from
'
vscode
'
;
import
{
ExtensionContext
,
workspace
,
window
,
Disposable
,
commands
,
Uri
,
scm
}
from
'
vscode
'
;
import
{
findGit
,
Git
}
from
'
./git
'
;
import
{
Model
}
from
'
./model
'
;
import
{
GitSCMProvider
}
from
'
./scmProvider
'
;
...
...
@@ -14,7 +14,6 @@ import { CheckoutStatusBar, SyncStatusBar } from './statusbar';
import
{
GitContentProvider
}
from
'
./contentProvider
'
;
import
{
AutoFetcher
}
from
'
./autofetch
'
;
import
{
MergeDecorator
}
from
'
./merge
'
;
import
{
CommitController
}
from
'
./commit
'
;
import
{
Askpass
}
from
'
./askpass
'
;
import
*
as
nls
from
'
vscode-nls
'
;
...
...
@@ -43,7 +42,6 @@ async function init(disposables: Disposable[]): Promise<void> {
outputChannel
.
appendLine
(
localize
(
'
using git
'
,
"
Using git {0} from {1}
"
,
info
.
version
,
info
.
path
));
git
.
onOutput
(
str
=>
outputChannel
.
append
(
str
),
null
,
disposables
);
const
commitHandler
=
new
CommitController
();
const
commandCenter
=
new
CommandCenter
(
model
,
outputChannel
);
const
provider
=
new
GitSCMProvider
(
model
,
commandCenter
);
const
contentProvider
=
new
GitContentProvider
(
model
);
...
...
@@ -53,7 +51,6 @@ async function init(disposables: Disposable[]): Promise<void> {
const
mergeDecorator
=
new
MergeDecorator
(
model
);
disposables
.
push
(
commitHandler
,
commandCenter
,
provider
,
contentProvider
,
...
...
@@ -72,6 +69,8 @@ async function init(disposables: Disposable[]): Promise<void> {
commands
.
executeCommand
(
'
vscode.open
'
,
Uri
.
parse
(
'
https://git-scm.com/
'
));
}
}
scm
.
inputBox
.
value
=
await
model
.
getCommitTemplate
();
}
export
function
activate
(
context
:
ExtensionContext
):
any
{
...
...
extensions/git/src/model.ts
浏览文件 @
66c24011
...
...
@@ -184,7 +184,8 @@ export enum Operation {
Sync
=
1
<<
11
,
Init
=
1
<<
12
,
Show
=
1
<<
13
,
Stage
=
1
<<
13
Stage
=
1
<<
14
,
GetCommitTemplate
=
1
<<
15
}
export
interface
Operations
{
...
...
@@ -455,6 +456,10 @@ export class Model implements Disposable {
});
}
async
getCommitTemplate
():
Promise
<
string
>
{
return
await
this
.
run
(
Operation
.
GetCommitTemplate
,
async
()
=>
this
.
repository
.
getCommitTemplate
());
}
private
async
run
<
T
>
(
operation
:
Operation
,
runOperation
:
()
=>
Promise
<
T
>
=
()
=>
Promise
.
resolve
<
any
>
(
null
)):
Promise
<
T
>
{
return
window
.
withScmProgress
(
async
()
=>
{
this
.
_operations
=
this
.
_operations
.
start
(
operation
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录