Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
vnotepad
Exa
提交
d9319c48
E
Exa
项目概览
vnotepad
/
Exa
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
Exa
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d9319c48
编写于
5月 10, 2015
作者:
B
Ben S
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Do the same for the Git column
上级
5a37d1b6
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
42 addition
and
23 deletion
+42
-23
src/colours.rs
src/colours.rs
+18
-0
src/dir.rs
src/dir.rs
+4
-3
src/feature/git.rs
src/feature/git.rs
+17
-17
src/file.rs
src/file.rs
+3
-3
未找到文件。
src/colours.rs
浏览文件 @
d9319c48
...
...
@@ -13,6 +13,7 @@ pub struct Colours {
pub
size
:
Size
,
pub
users
:
Users
,
pub
links
:
Links
,
pub
git
:
Git
,
pub
punctuation
:
Style
,
pub
date
:
Style
,
...
...
@@ -82,6 +83,15 @@ pub struct Links {
pub
multi_link_file
:
Style
,
}
#[derive(Clone,
Copy,
Debug,
Default,
PartialEq)]
pub
struct
Git
{
pub
new
:
Style
,
pub
modified
:
Style
,
pub
deleted
:
Style
,
pub
renamed
:
Style
,
pub
typechange
:
Style
,
}
impl
Colours
{
pub
fn
plain
()
->
Colours
{
Colours
::
default
()
...
...
@@ -138,6 +148,14 @@ impl Colours {
multi_link_file
:
Red
.on
(
Yellow
),
},
git
:
Git
{
new
:
Green
.normal
(),
modified
:
Blue
.normal
(),
deleted
:
Red
.normal
(),
renamed
:
Yellow
.normal
(),
typechange
:
Purple
.normal
(),
},
punctuation
:
Fixed
(
244
)
.normal
(),
date
:
Blue
.normal
(),
inode
:
Purple
.normal
(),
...
...
src/dir.rs
浏览文件 @
d9319c48
use
colours
::
Colours
;
use
feature
::
Git
;
use
file
::{
File
,
GREY
};
...
...
@@ -64,10 +65,10 @@ impl Dir {
}
/// Get a string describing the Git status of the given file.
pub
fn
git_status
(
&
self
,
path
:
&
Path
,
prefix_lookup
:
bool
)
->
String
{
pub
fn
git_status
(
&
self
,
path
:
&
Path
,
colours
:
&
Colours
,
prefix_lookup
:
bool
)
->
String
{
match
(
&
self
.git
,
prefix_lookup
)
{
(
&
Some
(
ref
git
),
false
)
=>
git
.status
(
path
),
(
&
Some
(
ref
git
),
true
)
=>
git
.dir_status
(
path
),
(
&
Some
(
ref
git
),
false
)
=>
git
.status
(
colours
,
path
),
(
&
Some
(
ref
git
),
true
)
=>
git
.dir_status
(
colours
,
path
),
(
&
None
,
_
)
=>
GREY
.paint
(
"--"
)
.to_string
(),
}
}
...
...
src/feature/git.rs
浏览文件 @
d9319c48
use
std
::
path
::{
Path
,
PathBuf
};
use
ansi_term
::{
ANSIString
,
ANSIStrings
};
use
ansi_term
::
Colour
::
*
;
use
git2
;
use
colours
::
Colours
;
use
file
::
GREY
;
/// Container of Git statuses for all the files in this folder's Git repository.
...
...
@@ -30,11 +30,11 @@ impl Git {
}
/// Get the status for the file at the given path, if present.
pub
fn
status
(
&
self
,
path
:
&
Path
)
->
String
{
pub
fn
status
(
&
self
,
c
:
&
Colours
,
path
:
&
Path
)
->
String
{
let
status
=
self
.statuses
.iter
()
.find
(|
p
|
p
.0
.as_path
()
==
path
);
match
status
{
Some
(
&
(
_
,
s
))
=>
ANSIStrings
(
&
[
Git
::
index_status
(
s
),
Git
::
working_tree_status
(
s
)
])
.to_string
(),
Some
(
&
(
_
,
s
))
=>
ANSIStrings
(
&
[
Git
::
index_status
(
c
,
s
),
Git
::
working_tree_status
(
c
,
s
)
])
.to_string
(),
None
=>
GREY
.paint
(
"--"
)
.to_string
(),
}
}
...
...
@@ -42,35 +42,35 @@ impl Git {
/// Get the combined status for all the files whose paths begin with the
/// path that gets passed in. This is used for getting the status of
/// directories, which don't really have an 'official' status.
pub
fn
dir_status
(
&
self
,
dir
:
&
Path
)
->
String
{
pub
fn
dir_status
(
&
self
,
c
:
&
Colours
,
dir
:
&
Path
)
->
String
{
let
s
=
self
.statuses
.iter
()
.filter
(|
p
|
p
.0
.starts_with
(
dir
))
.fold
(
git2
::
Status
::
empty
(),
|
a
,
b
|
a
|
b
.1
);
ANSIStrings
(
&
[
Git
::
index_status
(
s
),
Git
::
working_tree_status
(
s
)]
)
.to_string
()
ANSIStrings
(
&
[
Git
::
index_status
(
c
,
s
),
Git
::
working_tree_status
(
c
,
s
)]
)
.to_string
()
}
/// The character to display if the file has been modified, but not staged.
fn
working_tree_status
(
status
:
git2
::
Status
)
->
ANSIString
<
'static
>
{
fn
working_tree_status
(
colours
:
&
Colours
,
status
:
git2
::
Status
)
->
ANSIString
<
'static
>
{
match
status
{
s
if
s
.contains
(
git2
::
STATUS_WT_NEW
)
=>
Green
.paint
(
"A"
),
s
if
s
.contains
(
git2
::
STATUS_WT_MODIFIED
)
=>
Blue
.paint
(
"M"
),
s
if
s
.contains
(
git2
::
STATUS_WT_DELETED
)
=>
R
ed
.paint
(
"D"
),
s
if
s
.contains
(
git2
::
STATUS_WT_RENAMED
)
=>
Yellow
.paint
(
"R"
),
s
if
s
.contains
(
git2
::
STATUS_WT_TYPECHANGE
)
=>
Purpl
e
.paint
(
"T"
),
s
if
s
.contains
(
git2
::
STATUS_WT_NEW
)
=>
colours
.git.new
.paint
(
"A"
),
s
if
s
.contains
(
git2
::
STATUS_WT_MODIFIED
)
=>
colours
.git.modified
.paint
(
"M"
),
s
if
s
.contains
(
git2
::
STATUS_WT_DELETED
)
=>
colours
.git.delet
ed
.paint
(
"D"
),
s
if
s
.contains
(
git2
::
STATUS_WT_RENAMED
)
=>
colours
.git.renamed
.paint
(
"R"
),
s
if
s
.contains
(
git2
::
STATUS_WT_TYPECHANGE
)
=>
colours
.git.typechang
e
.paint
(
"T"
),
_
=>
GREY
.paint
(
"-"
),
}
}
/// The character to display if the file has been modified, and the change
/// has been staged.
fn
index_status
(
status
:
git2
::
Status
)
->
ANSIString
<
'static
>
{
fn
index_status
(
colours
:
&
Colours
,
status
:
git2
::
Status
)
->
ANSIString
<
'static
>
{
match
status
{
s
if
s
.contains
(
git2
::
STATUS_INDEX_NEW
)
=>
Green
.paint
(
"A"
),
s
if
s
.contains
(
git2
::
STATUS_INDEX_MODIFIED
)
=>
Blue
.paint
(
"M"
),
s
if
s
.contains
(
git2
::
STATUS_INDEX_DELETED
)
=>
R
ed
.paint
(
"D"
),
s
if
s
.contains
(
git2
::
STATUS_INDEX_RENAMED
)
=>
Yellow
.paint
(
"R"
),
s
if
s
.contains
(
git2
::
STATUS_INDEX_TYPECHANGE
)
=>
Purpl
e
.paint
(
"T"
),
s
if
s
.contains
(
git2
::
STATUS_INDEX_NEW
)
=>
colours
.git.new
.paint
(
"A"
),
s
if
s
.contains
(
git2
::
STATUS_INDEX_MODIFIED
)
=>
colours
.git.modified
.paint
(
"M"
),
s
if
s
.contains
(
git2
::
STATUS_INDEX_DELETED
)
=>
colours
.git.delet
ed
.paint
(
"D"
),
s
if
s
.contains
(
git2
::
STATUS_INDEX_RENAMED
)
=>
colours
.git.renamed
.paint
(
"R"
),
s
if
s
.contains
(
git2
::
STATUS_INDEX_TYPECHANGE
)
=>
colours
.git.typechang
e
.paint
(
"T"
),
_
=>
GREY
.paint
(
"-"
),
}
}
...
...
src/file.rs
浏览文件 @
d9319c48
...
...
@@ -124,7 +124,7 @@ impl<'a> File<'a> {
Blocks
=>
self
.blocks
(
colours
,
&
locale
.numeric
),
User
=>
self
.user
(
colours
,
users_cache
),
Group
=>
self
.group
(
colours
,
users_cache
),
GitStatus
=>
self
.git_status
(),
GitStatus
=>
self
.git_status
(
colours
),
}
}
...
...
@@ -475,7 +475,7 @@ impl<'a> File<'a> {
choices
.contains
(
&&
self
.name
[
..
])
}
fn
git_status
(
&
self
)
->
Cell
{
fn
git_status
(
&
self
,
colours
:
&
Colours
)
->
Cell
{
let
status
=
match
self
.dir
{
None
=>
GREY
.paint
(
"--"
)
.to_string
(),
Some
(
d
)
=>
{
...
...
@@ -484,7 +484,7 @@ impl<'a> File<'a> {
Ok
(
dir
)
=>
dir
.join
(
&
self
.path
),
};
d
.git_status
(
&
cwd
,
self
.is_directory
())
d
.git_status
(
&
cwd
,
colours
,
self
.is_directory
())
},
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录