Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
e7570250
Commit
e7570250
authored
Oct 21, 2011
by
gitlabhq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix #140, commit lil refactor
parent
32f4dc7c
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
38 deletions
+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
No files found.
app/models/project.rb
View file @
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
View file @
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
View file @
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
View file @
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
View file @
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"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment