BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
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
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
82 additions
and
68 deletions
+82
-68
commit.rb
app/models/commit.rb
+60
-0
project.rb
app/models/project.rb
+7
-40
repository.rb
app/models/repository.rb
+0
-13
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
:id
,
: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?
false
end
...
...
app/models/project.rb
View file @
cd06d6ed
...
...
@@ -69,7 +69,7 @@ class Project < ActiveRecord::Base
:project
=>
self
,
:action
=>
Event
::
Pushed
,
:data
=>
data
,
:author_id
=>
Key
.
find_by_identifier
(
author_key_id
).
user
.
id
:author_id
=>
data
[
:user_id
]
)
end
...
...
@@ -259,60 +259,27 @@ class Project < ActiveRecord::Base
end
def
commit
(
commit_id
=
nil
)
commit
=
if
commit_id
repo
.
commit
(
commit_id
)
else
repo
.
commits
.
first
end
Commit
.
new
(
commit
)
if
commit
Commit
.
find_or_first
(
repo
,
commit_id
)
end
def
fresh_commits
(
n
=
10
)
commits
=
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
]
Commit
.
fresh_commits
(
repo
,
n
)
end
def
commits_with_refs
(
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
]
Commit
.
commits_with_refs
(
repo
,
n
)
end
def
commits_since
(
date
)
commits
=
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
Commit
.
commits_since
(
repo
,
date
)
end
def
commits
(
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
)
}
Commit
.
commits
(
repo
,
ref
,
path
,
limit
,
offset
)
end
def
commits_between
(
from
,
to
)
repo
.
commits_between
(
from
,
to
).
map
{
|
c
|
Commit
.
new
(
c
)
}
Commit
.
commits_between
(
repo
,
from
,
to
)
end
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
,
[
{
:id
=>
1
,
:project_id
=>
1
,
:user_id
=>
1
,
:project_access
=>
Project
::
PROJECT_RWA
,
:repo_access
=>
Repository
::
REPO_RW
},
{
:id
=>
2
,
:project_id
=>
1
,
:user_id
=>
2
,
:project_access
=>
Project
::
PROJECT_RW
,
:repo_access
=>
Repository
::
REPO_N
},
{
:id
=>
3
,
:project_id
=>
1
,
:user_id
=>
3
,
:project_access
=>
Project
::
PROJECT_RW
,
:repo_access
=>
Repository
::
REPO_N
},
{
:id
=>
4
,
:project_id
=>
1
,
:user_id
=>
4
,
:project_access
=>
Project
::
PROJECT_R
,
:repo_access
=>
Repository
::
REPO_N
},
{
:id
=>
5
,
:project_id
=>
1
,
:user_id
=>
5
,
:project_access
=>
Project
::
PROJECT_R
,
:repo_access
=>
Repository
::
REPO_N
},
{
:id
=>
1
,
:project_id
=>
1
,
:user_id
=>
1
,
:project_access
=>
UsersProject
::
MASTER
},
{
:id
=>
2
,
:project_id
=>
1
,
:user_id
=>
2
,
:project_access
=>
UsersProject
::
REPORTERW
},
{
:id
=>
3
,
:project_id
=>
1
,
:user_id
=>
3
,
:project_access
=>
UsersProject
::
REPORTERW
},
{
:id
=>
4
,
:project_id
=>
1
,
:user_id
=>
4
,
:project_access
=>
UsersProject
::
REPORTER
},
{
: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
=>
7
,
:project_id
=>
2
,
:user_id
=>
2
,
:project_access
=>
Project
::
PROJECT_R
,
:repo_access
=>
Repository
::
REPO_N
},
{
:id
=>
8
,
:project_id
=>
2
,
:user_id
=>
3
,
:project_access
=>
Project
::
PROJECT_R
,
:repo_access
=>
Repository
::
REPO_N
},
{
:id
=>
9
,
:project_id
=>
2
,
:user_id
=>
4
,
:project_access
=>
Project
::
PROJECT_RWA
,
:repo_access
=>
Repository
::
REPO_N
},
{
:id
=>
11
,
:project_id
=>
2
,
:user_id
=>
5
,
:project_access
=>
Project
::
PROJECT_RWA
,
:repo_access
=>
Repository
::
REPO_N
},
{
:id
=>
6
,
:project_id
=>
2
,
:user_id
=>
1
,
:project_access
=>
UsersProject
::
MASTER
},
{
:id
=>
7
,
:project_id
=>
2
,
:user_id
=>
2
,
:project_access
=>
UsersProject
::
REPORTER
},
{
:id
=>
8
,
:project_id
=>
2
,
:user_id
=>
3
,
:project_access
=>
UsersProject
::
REPORTER
},
{
:id
=>
9
,
:project_id
=>
2
,
:user_id
=>
4
,
:project_access
=>
UsersProject
::
MASTER
},
{
: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
=>
13
,
:project_id
=>
3
,
:user_id
=>
2
,
:project_access
=>
Project
::
PROJECT_R
,
:repo_access
=>
Repository
::
REPO_N
},
{
:id
=>
14
,
:project_id
=>
3
,
:user_id
=>
3
,
:project_access
=>
Project
::
PROJECT_RWA
,
:repo_access
=>
Repository
::
REPO_N
},
{
:id
=>
15
,
:project_id
=>
3
,
:user_id
=>
4
,
:project_access
=>
Project
::
PROJECT_R
,
:repo_access
=>
Repository
::
REPO_N
},
{
:id
=>
16
,
:project_id
=>
3
,
:user_id
=>
5
,
:project_access
=>
Project
::
PROJECT_RWA
,
:repo_access
=>
Repository
::
REPO_N
}
{
:id
=>
12
,
:project_id
=>
3
,
:user_id
=>
1
,
:project_access
=>
UsersProject
::
MASTER
},
{
:id
=>
13
,
:project_id
=>
3
,
:user_id
=>
2
,
:project_access
=>
UsersProject
::
REPORTER
},
{
:id
=>
14
,
:project_id
=>
3
,
:user_id
=>
3
,
:project_access
=>
UsersProject
::
MASTER
},
{
:id
=>
15
,
:project_id
=>
3
,
:user_id
=>
4
,
:project_access
=>
UsersProject
::
REPORTER
},
{
: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