Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
vnotepad
Exa
提交
e21dc9af
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,体验更适合开发者的 AI 搜索 >>
提交
e21dc9af
编写于
2月 23, 2015
作者:
B
Ben S
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #21 from coyotebush/git-paths
Improve matching of Git status entries to files
上级
ee20c5d8
6e195638
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
8 addition
and
5 deletion
+8
-5
src/dir.rs
src/dir.rs
+5
-4
src/file.rs
src/file.rs
+3
-1
未找到文件。
src/dir.rs
浏览文件 @
e21dc9af
...
...
@@ -75,7 +75,7 @@ impl Dir {
/// Container of Git statuses for all the files in this folder's Git repository.
#[cfg(feature=
"git"
)]
struct
Git
{
statuses
:
Vec
<
(
Vec
<
u8
>
,
git2
::
Status
)
>
,
statuses
:
Vec
<
(
Path
,
git2
::
Status
)
>
,
}
#[cfg(feature=
"git"
)]
...
...
@@ -85,8 +85,9 @@ impl Git {
/// the files' statuses if one is found.
fn
scan
(
path
:
&
Path
)
->
Result
<
Git
,
git2
::
Error
>
{
let
repo
=
try!
(
git2
::
Repository
::
discover
(
path
));
let
workdir
=
repo
.workdir
()
.unwrap_or
(
Path
::
new
(
"."
));
let
statuses
=
try!
(
repo
.statuses
(
None
))
.iter
()
.map
(|
e
|
(
e
.path_bytes
()
.to_vec
(
),
e
.status
()))
.map
(|
e
|
(
workdir
.join
(
e
.path_bytes
()
),
e
.status
()))
.collect
();
Ok
(
Git
{
statuses
:
statuses
})
}
...
...
@@ -94,7 +95,7 @@ impl Git {
/// Get the status for the file at the given path, if present.
fn
status
(
&
self
,
path
:
&
Path
)
->
String
{
let
status
=
self
.statuses
.iter
()
.find
(|
p
|
p
.0
==
path
.as_vec
()
);
.find
(|
p
|
&
p
.0
==
path
);
match
status
{
Some
(
&
(
_
,
s
))
=>
ANSIStrings
(
&
[
Git
::
index_status
(
s
),
Git
::
working_tree_status
(
s
)
])
.to_string
(),
None
=>
GREY
.paint
(
"--"
)
.to_string
(),
...
...
@@ -106,7 +107,7 @@ impl Git {
/// directories, which don't really have an 'official' status.
fn
dir_status
(
&
self
,
dir
:
&
Path
)
->
String
{
let
s
=
self
.statuses
.iter
()
.filter
(|
p
|
p
.0
.starts_with
(
dir
.as_vec
()
))
.filter
(|
p
|
dir
.is_ancestor_of
(
&
p
.0
))
.fold
(
git2
::
Status
::
empty
(),
|
a
,
b
|
a
|
b
.1
);
ANSIStrings
(
&
[
Git
::
index_status
(
s
),
Git
::
working_tree_status
(
s
)]
)
.to_string
()
...
...
src/file.rs
浏览文件 @
e21dc9af
use
std
::
old_io
::{
fs
,
IoResult
};
use
std
::
old_io
as
io
;
use
std
::
ascii
::
AsciiExt
;
use
std
::
env
::
current_dir
;
use
ansi_term
::{
ANSIString
,
ANSIStrings
,
Colour
,
Style
};
use
ansi_term
::
Style
::
Plain
;
...
...
@@ -415,7 +416,8 @@ impl<'a> File<'a> {
fn
git_status
(
&
self
)
->
Cell
{
let
status
=
match
self
.dir
{
Some
(
d
)
=>
d
.git_status
(
&
self
.path
,
self
.stat.kind
==
io
::
FileType
::
Directory
),
Some
(
d
)
=>
d
.git_status
(
&
current_dir
()
.unwrap_or
(
Path
::
new
(
"."
))
.join
(
&
self
.path
),
self
.stat.kind
==
io
::
FileType
::
Directory
),
None
=>
GREY
.paint
(
"--"
)
.to_string
(),
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录