Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
e7570250
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
e7570250
编写于
10月 21, 2011
作者:
G
gitlabhq
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix #140, commit lil refactor
上级
32f4dc7c
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
59 addition
and
38 deletion
+59
-38
app/models/project.rb
app/models/project.rb
+8
-0
app/views/commits/_diff.html.haml
app/views/commits/_diff.html.haml
+3
-38
app/views/commits/_diff_head.html.haml
app/views/commits/_diff_head.html.haml
+24
-0
app/views/commits/_text_file.html.haml
app/views/commits/_text_file.html.haml
+15
-0
spec/models/project_spec.rb
spec/models/project_spec.rb
+9
-0
未找到文件。
app/models/project.rb
浏览文件 @
e7570250
...
...
@@ -36,6 +36,8 @@ class Project < ActiveRecord::Base
validate
:check_limit
validate
:repo_name
after_destroy
:destroy_gitosis_project
after_save
:update_gitosis_project
...
...
@@ -168,6 +170,12 @@ class Project < ActiveRecord::Base
errors
[
:base
]
<<
(
"Cant check your ability to create project"
)
end
def
repo_name
if
path
==
"gitosis-admin"
errors
.
add
(
:path
,
"Project path like 'gitosis-admin' is not allowed"
)
end
end
def
valid_repo?
repo
rescue
...
...
app/views/commits/_diff.html.haml
浏览文件 @
e7570250
.file_stats
-
@commit
.
diffs
.
each
do
|
diff
|
-
if
diff
.
deleted_file
%span
.removed_file
%a
{
:href
=>
"##{diff.a_path}"
}
=
diff
.
a_path
=
image_tag
"blueprint_delete.png"
-
elsif
diff
.
renamed_file
%span
.moved_file
%a
{
:href
=>
"##{diff.b_path}"
}
=
diff
.
a_path
=
"->"
=
diff
.
b_path
=
image_tag
"blueprint_notice.png"
-
elsif
diff
.
new_file
%span
.new_file
%a
{
:href
=>
"##{diff.b_path}"
}
=
diff
.
b_path
=
image_tag
"blueprint_add.png"
-
else
%span
.edit_file
%a
{
:href
=>
"##{diff.b_path}"
}
=
diff
.
b_path
=
image_tag
"blueprint_info.png"
.file_stats
=
render
"commits/diff_head"
-
@commit
.
diffs
.
each
do
|
diff
|
-
next
if
diff
.
diff
.
empty?
-
file
=
(
@commit
.
tree
/
diff
.
b_path
)
...
...
@@ -36,20 +14,7 @@
%br
/
.diff_file_content
-
if
file
.
text?
-
lines_arr
=
diff
.
diff
.
lines
.
to_a
-
line_old
=
lines_arr
[
2
].
match
(
/-(\d)/
)[
0
].
to_i
.
abs
rescue
0
-
line_new
=
lines_arr
[
2
].
match
(
/\+(\d)/
)[
0
].
to_i
.
abs
rescue
0
-
lines
=
lines_arr
[
3
..-
1
].
join
-
lines
.
each_line
do
|
line
|
=
diff_line
(
line
,
line_new
,
line_old
)
-
if
line
[
0
]
==
"+"
-
line_new
+=
1
-
elsif
-
line
[
0
]
==
"-"
-
line_old
+=
1
-
else
-
line_new
+=
1
-
line_old
+=
1
=
render
:partial
=>
"commits/text_file"
,
:locals
=>
{
:diff
=>
diff
}
-
elsif
file
.
image?
.diff_file_content_image
%img
{
:src
=>
"data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"
}
...
...
app/views/commits/_diff_head.html.haml
0 → 100644
浏览文件 @
e7570250
-
@commit
.
diffs
.
each
do
|
diff
|
-
if
diff
.
deleted_file
%span
.removed_file
%a
{
:href
=>
"##{diff.a_path}"
}
=
diff
.
a_path
=
image_tag
"blueprint_delete.png"
-
elsif
diff
.
renamed_file
%span
.moved_file
%a
{
:href
=>
"##{diff.b_path}"
}
=
diff
.
a_path
=
"->"
=
diff
.
b_path
=
image_tag
"blueprint_notice.png"
-
elsif
diff
.
new_file
%span
.new_file
%a
{
:href
=>
"##{diff.b_path}"
}
=
diff
.
b_path
=
image_tag
"blueprint_add.png"
-
else
%span
.edit_file
%a
{
:href
=>
"##{diff.b_path}"
}
=
diff
.
b_path
=
image_tag
"blueprint_info.png"
app/views/commits/_text_file.html.haml
0 → 100644
浏览文件 @
e7570250
-
lines_arr
=
diff
.
diff
.
lines
.
to_a
-
line_old
=
lines_arr
[
2
].
match
(
/-(\d)/
)[
0
].
to_i
.
abs
rescue
0
-
line_new
=
lines_arr
[
2
].
match
(
/\+(\d)/
)[
0
].
to_i
.
abs
rescue
0
-
lines
=
lines_arr
[
3
..-
1
].
join
-
lines
.
each_line
do
|
line
|
=
diff_line
(
line
,
line_new
,
line_old
)
-
if
line
[
0
]
==
"+"
-
line_new
+=
1
-
elsif
-
line
[
0
]
==
"-"
-
line_old
+=
1
-
else
-
line_new
+=
1
-
line_old
+=
1
spec/models/project_spec.rb
浏览文件 @
e7570250
...
...
@@ -4,11 +4,15 @@ describe Project do
describe
"Associations"
do
it
{
should
have_many
(
:users
)
}
it
{
should
have_many
(
:users_projects
)
}
it
{
should
have_many
(
:issues
)
}
it
{
should
have_many
(
:notes
)
}
it
{
should
have_many
(
:snippets
)
}
end
describe
"Validation"
do
it
{
should
validate_presence_of
(
:name
)
}
it
{
should
validate_presence_of
(
:path
)
}
it
{
should
validate_presence_of
(
:code
)
}
end
describe
"Respond to"
do
...
...
@@ -31,6 +35,11 @@ describe Project do
it
{
should
respond_to
(
:commit
)
}
end
it
"should not allow 'gitosis-admin' as repo name"
do
should
allow_value
(
"blah"
).
for
(
:path
)
should_not
allow_value
(
"gitosis-admin"
).
for
(
:path
)
end
it
"should return valid url to repo"
do
project
=
Project
.
new
(
:path
=>
"somewhere"
)
project
.
url_to_repo
.
should
==
"git@localhost:somewhere.git"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录