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
cd06d6ed
Commit
cd06d6ed
authored
Mar 09, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Project model refactored
parent
9988282e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
82 additions
and
68 deletions
+82
-68
app/models/commit.rb
app/models/commit.rb
+60
-0
app/models/project.rb
app/models/project.rb
+7
-40
app/models/repository.rb
app/models/repository.rb
+0
-13
db/fixtures/development/004_teams.rb
db/fixtures/development/004_teams.rb
+15
-15
No files found.
app/models/commit.rb
View file @
cd06d6ed
...
@@ -20,6 +20,66 @@ class Commit
...
@@ -20,6 +20,66 @@ class Commit
:id
,
:id
,
:to
=>
:commit
:to
=>
:commit
class
<<
self
def
find_or_first
(
repo
,
commit_id
=
nil
)
commit
=
if
commit_id
repo
.
commit
(
commit_id
)
else
repo
.
commits
.
first
end
Commit
.
new
(
commit
)
if
commit
end
def
fresh_commits
(
repo
,
n
=
10
)
commits
=
repo
.
heads
.
map
do
|
h
|
repo
.
commits
(
h
.
name
,
n
).
map
{
|
c
|
Commit
.
new
(
c
,
h
)
}
end
.
flatten
.
uniq
{
|
c
|
c
.
id
}
commits
.
sort!
do
|
x
,
y
|
y
.
committed_date
<=>
x
.
committed_date
end
commits
[
0
...
n
]
end
def
commits_with_refs
(
repo
,
n
=
20
)
commits
=
repo
.
branches
.
map
{
|
ref
|
Commit
.
new
(
ref
.
commit
,
ref
)
}
commits
.
sort!
do
|
x
,
y
|
y
.
committed_date
<=>
x
.
committed_date
end
commits
[
0
..
n
]
end
def
commits_since
(
repo
,
date
)
commits
=
repo
.
heads
.
map
do
|
h
|
repo
.
log
(
h
.
name
,
nil
,
:since
=>
date
).
each
{
|
c
|
Commit
.
new
(
c
,
h
)
}
end
.
flatten
.
uniq
{
|
c
|
c
.
id
}
commits
.
sort!
do
|
x
,
y
|
y
.
committed_date
<=>
x
.
committed_date
end
commits
end
def
commits
(
repo
,
ref
,
path
=
nil
,
limit
=
nil
,
offset
=
nil
)
if
path
repo
.
log
(
ref
,
path
,
:max_count
=>
limit
,
:skip
=>
offset
)
elsif
limit
&&
offset
repo
.
commits
(
ref
,
limit
,
offset
)
else
repo
.
commits
(
ref
)
end
.
map
{
|
c
|
Commit
.
new
(
c
)
}
end
def
commits_between
(
repo
,
from
,
to
)
repo
.
commits_between
(
from
,
to
).
map
{
|
c
|
Commit
.
new
(
c
)
}
end
end
def
persisted?
def
persisted?
false
false
end
end
...
...
app/models/project.rb
View file @
cd06d6ed
...
@@ -69,7 +69,7 @@ class Project < ActiveRecord::Base
...
@@ -69,7 +69,7 @@ class Project < ActiveRecord::Base
:project
=>
self
,
:project
=>
self
,
:action
=>
Event
::
Pushed
,
:action
=>
Event
::
Pushed
,
:data
=>
data
,
:data
=>
data
,
:author_id
=>
Key
.
find_by_identifier
(
author_key_id
).
user
.
id
:author_id
=>
data
[
:user_id
]
)
)
end
end
...
@@ -259,60 +259,27 @@ class Project < ActiveRecord::Base
...
@@ -259,60 +259,27 @@ class Project < ActiveRecord::Base
end
end
def
commit
(
commit_id
=
nil
)
def
commit
(
commit_id
=
nil
)
commit
=
if
commit_id
Commit
.
find_or_first
(
repo
,
commit_id
)
repo
.
commit
(
commit_id
)
else
repo
.
commits
.
first
end
Commit
.
new
(
commit
)
if
commit
end
end
def
fresh_commits
(
n
=
10
)
def
fresh_commits
(
n
=
10
)
commits
=
heads
.
map
do
|
h
|
Commit
.
fresh_commits
(
repo
,
n
)
repo
.
commits
(
h
.
name
,
n
).
map
{
|
c
|
Commit
.
new
(
c
,
h
)
}
end
.
flatten
.
uniq
{
|
c
|
c
.
id
}
commits
.
sort!
do
|
x
,
y
|
y
.
committed_date
<=>
x
.
committed_date
end
commits
[
0
...
n
]
end
end
def
commits_with_refs
(
n
=
20
)
def
commits_with_refs
(
n
=
20
)
commits
=
repo
.
branches
.
map
{
|
ref
|
Commit
.
new
(
ref
.
commit
,
ref
)
}
Commit
.
commits_with_refs
(
repo
,
n
)
commits
.
sort!
do
|
x
,
y
|
y
.
committed_date
<=>
x
.
committed_date
end
commits
[
0
..
n
]
end
end
def
commits_since
(
date
)
def
commits_since
(
date
)
commits
=
heads
.
map
do
|
h
|
Commit
.
commits_since
(
repo
,
date
)
repo
.
log
(
h
.
name
,
nil
,
:since
=>
date
).
each
{
|
c
|
Commit
.
new
(
c
,
h
)
}
end
.
flatten
.
uniq
{
|
c
|
c
.
id
}
commits
.
sort!
do
|
x
,
y
|
y
.
committed_date
<=>
x
.
committed_date
end
commits
end
end
def
commits
(
ref
,
path
=
nil
,
limit
=
nil
,
offset
=
nil
)
def
commits
(
ref
,
path
=
nil
,
limit
=
nil
,
offset
=
nil
)
if
path
Commit
.
commits
(
repo
,
ref
,
path
,
limit
,
offset
)
repo
.
log
(
ref
,
path
,
:max_count
=>
limit
,
:skip
=>
offset
)
elsif
limit
&&
offset
repo
.
commits
(
ref
,
limit
,
offset
)
else
repo
.
commits
(
ref
)
end
.
map
{
|
c
|
Commit
.
new
(
c
)
}
end
end
def
commits_between
(
from
,
to
)
def
commits_between
(
from
,
to
)
repo
.
commits_between
(
from
,
to
).
map
{
|
c
|
Commit
.
new
(
c
)
}
Commit
.
commits_between
(
repo
,
from
,
to
)
end
end
def
project_id
def
project_id
...
...
app/models/repository.rb
deleted
100644 → 0
View file @
9988282e
require
File
.
join
(
Rails
.
root
,
"lib"
,
"gitlabhq"
,
"git_host"
)
class
Repository
attr_accessor
:project
def
self
.
default_ref
"master"
end
def
self
.
access_options
{}
end
end
db/fixtures/development/004_teams.rb
View file @
cd06d6ed
UsersProject
.
seed
(
:id
,
[
UsersProject
.
seed
(
:id
,
[
{
:id
=>
1
,
:project_id
=>
1
,
:user_id
=>
1
,
:project_access
=>
Project
::
PROJECT_RWA
,
:repo_access
=>
Repository
::
REPO_RW
},
{
:id
=>
1
,
:project_id
=>
1
,
:user_id
=>
1
,
:project_access
=>
UsersProject
::
MASTER
},
{
:id
=>
2
,
:project_id
=>
1
,
:user_id
=>
2
,
:project_access
=>
Project
::
PROJECT_RW
,
:repo_access
=>
Repository
::
REPO_N
},
{
:id
=>
2
,
:project_id
=>
1
,
:user_id
=>
2
,
:project_access
=>
UsersProject
::
REPORTERW
},
{
:id
=>
3
,
:project_id
=>
1
,
:user_id
=>
3
,
:project_access
=>
Project
::
PROJECT_RW
,
:repo_access
=>
Repository
::
REPO_N
},
{
:id
=>
3
,
:project_id
=>
1
,
:user_id
=>
3
,
:project_access
=>
UsersProject
::
REPORTERW
},
{
:id
=>
4
,
:project_id
=>
1
,
:user_id
=>
4
,
:project_access
=>
Project
::
PROJECT_R
,
:repo_access
=>
Repository
::
REPO_N
},
{
:id
=>
4
,
:project_id
=>
1
,
:user_id
=>
4
,
:project_access
=>
UsersProject
::
REPORTER
},
{
:id
=>
5
,
:project_id
=>
1
,
:user_id
=>
5
,
:project_access
=>
Project
::
PROJECT_R
,
:repo_access
=>
Repository
::
REPO_N
},
{
:id
=>
5
,
:project_id
=>
1
,
:user_id
=>
5
,
:project_access
=>
UsersProject
::
REPORTER
},
{
:id
=>
6
,
:project_id
=>
2
,
:user_id
=>
1
,
:project_access
=>
Project
::
PROJECT_RWA
,
:repo_access
=>
Repository
::
REPO_RW
},
{
:id
=>
6
,
:project_id
=>
2
,
:user_id
=>
1
,
:project_access
=>
UsersProject
::
MASTER
},
{
:id
=>
7
,
:project_id
=>
2
,
:user_id
=>
2
,
:project_access
=>
Project
::
PROJECT_R
,
:repo_access
=>
Repository
::
REPO_N
},
{
:id
=>
7
,
:project_id
=>
2
,
:user_id
=>
2
,
:project_access
=>
UsersProject
::
REPORTER
},
{
:id
=>
8
,
:project_id
=>
2
,
:user_id
=>
3
,
:project_access
=>
Project
::
PROJECT_R
,
:repo_access
=>
Repository
::
REPO_N
},
{
:id
=>
8
,
:project_id
=>
2
,
:user_id
=>
3
,
:project_access
=>
UsersProject
::
REPORTER
},
{
:id
=>
9
,
:project_id
=>
2
,
:user_id
=>
4
,
:project_access
=>
Project
::
PROJECT_RWA
,
:repo_access
=>
Repository
::
REPO_N
},
{
:id
=>
9
,
:project_id
=>
2
,
:user_id
=>
4
,
:project_access
=>
UsersProject
::
MASTER
},
{
:id
=>
11
,
:project_id
=>
2
,
:user_id
=>
5
,
:project_access
=>
Project
::
PROJECT_RWA
,
:repo_access
=>
Repository
::
REPO_N
},
{
:id
=>
11
,
:project_id
=>
2
,
:user_id
=>
5
,
:project_access
=>
UsersProject
::
MASTER
},
{
:id
=>
12
,
:project_id
=>
3
,
:user_id
=>
1
,
:project_access
=>
Project
::
PROJECT_RWA
,
:repo_access
=>
Repository
::
REPO_RW
},
{
:id
=>
12
,
:project_id
=>
3
,
:user_id
=>
1
,
:project_access
=>
UsersProject
::
MASTER
},
{
:id
=>
13
,
:project_id
=>
3
,
:user_id
=>
2
,
:project_access
=>
Project
::
PROJECT_R
,
:repo_access
=>
Repository
::
REPO_N
},
{
:id
=>
13
,
:project_id
=>
3
,
:user_id
=>
2
,
:project_access
=>
UsersProject
::
REPORTER
},
{
:id
=>
14
,
:project_id
=>
3
,
:user_id
=>
3
,
:project_access
=>
Project
::
PROJECT_RWA
,
:repo_access
=>
Repository
::
REPO_N
},
{
:id
=>
14
,
:project_id
=>
3
,
:user_id
=>
3
,
:project_access
=>
UsersProject
::
MASTER
},
{
:id
=>
15
,
:project_id
=>
3
,
:user_id
=>
4
,
:project_access
=>
Project
::
PROJECT_R
,
:repo_access
=>
Repository
::
REPO_N
},
{
:id
=>
15
,
:project_id
=>
3
,
:user_id
=>
4
,
:project_access
=>
UsersProject
::
REPORTER
},
{
:id
=>
16
,
:project_id
=>
3
,
:user_id
=>
5
,
:project_access
=>
Project
::
PROJECT_RWA
,
:repo_access
=>
Repository
::
REPO_N
}
{
:id
=>
16
,
:project_id
=>
3
,
:user_id
=>
5
,
:project_access
=>
UsersProject
::
MASTER
}
])
])
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