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
8587e3a3
Commit
8587e3a3
authored
Jul 17, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
create corresponding events when create branch/tag with UI
parent
2a37db4c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
12 deletions
+36
-12
branches_controller.rb
app/controllers/projects/branches_controller.rb
+8
-4
tags_controller.rb
app/controllers/projects/tags_controller.rb
+9
-5
event.rb
app/models/event.rb
+11
-3
repository.rb
app/models/repository.rb
+8
-0
No files found.
app/controllers/projects/branches_controller.rb
View file @
8587e3a3
...
...
@@ -12,16 +12,20 @@ class Projects::BranchesController < Projects::ApplicationController
end
def
create
@project
.
repository
.
add_branch
(
params
[
:branch_name
],
params
[
:ref
])
@repository
.
add_branch
(
params
[
:branch_name
],
params
[
:ref
])
if
new_branch
=
@repository
.
find_branch
(
params
[
:branch_name
])
Event
.
create_ref_event
(
@project
,
current_user
,
new_branch
,
'add'
)
end
redirect_to
project_branches_path
(
@project
)
end
def
destroy
branch
=
@
project
.
repository
.
branches
.
find
{
|
branch
|
branch
.
name
==
params
[
:id
]
}
branch
=
@
repository
.
find_branch
(
params
[
:id
])
if
branch
&&
@
project
.
repository
.
rm_branch
(
branch
.
name
)
Event
.
create_r
m_ref
(
@project
,
current_user
,
branch
)
if
branch
&&
@repository
.
rm_branch
(
branch
.
name
)
Event
.
create_r
ef_event
(
@project
,
current_user
,
branch
,
'rm'
)
end
respond_to
do
|
format
|
...
...
app/controllers/projects/tags_controller.rb
View file @
8587e3a3
...
...
@@ -8,20 +8,24 @@ class Projects::TagsController < Projects::ApplicationController
before_filter
:authorize_admin_project!
,
only:
[
:destroy
]
def
index
@tags
=
Kaminari
.
paginate_array
(
@
project
.
repository
.
tags
).
page
(
params
[
:page
]).
per
(
30
)
@tags
=
Kaminari
.
paginate_array
(
@repository
.
tags
).
page
(
params
[
:page
]).
per
(
30
)
end
def
create
@project
.
repository
.
add_tag
(
params
[
:tag_name
],
params
[
:ref
])
@repository
.
add_tag
(
params
[
:tag_name
],
params
[
:ref
])
if
new_tag
=
@repository
.
find_tag
(
params
[
:tag_name
])
Event
.
create_ref_event
(
@project
,
current_user
,
new_tag
,
'add'
,
'refs/tags'
)
end
redirect_to
project_tags_path
(
@project
)
end
def
destroy
tag
=
@
project
.
repository
.
tags
.
find
{
|
tag
|
tag
.
name
==
params
[
:id
]
}
tag
=
@
repository
.
find_tag
(
params
[
:id
])
if
tag
&&
@
project
.
repository
.
rm_tag
(
tag
.
name
)
Event
.
create_r
m_ref
(
@project
,
current_user
,
tag
,
'refs/tags'
)
if
tag
&&
@repository
.
rm_tag
(
tag
.
name
)
Event
.
create_r
ef_event
(
@project
,
current_user
,
tag
,
'rm'
,
'refs/tags'
)
end
respond_to
do
|
format
|
...
...
app/models/event.rb
View file @
8587e3a3
...
...
@@ -55,14 +55,22 @@ class Event < ActiveRecord::Base
end
end
def
create_rm_ref
(
project
,
user
,
ref
,
prefix
=
'refs/heads'
)
def
create_ref_event
(
project
,
user
,
ref
,
action
=
'add'
,
prefix
=
'refs/heads'
)
if
action
.
to_s
==
'add'
before
=
'00000000'
after
=
ref
.
commit
.
id
else
before
=
ref
.
commit
.
id
after
=
'00000000'
end
Event
.
create
(
project:
project
,
action:
Event
::
PUSHED
,
data:
{
ref:
"
#{
prefix
}
/
#{
ref
.
name
}
"
,
before:
ref
.
commit
.
id
,
after:
'00000000'
before:
before
,
after:
after
},
author_id:
user
.
id
)
...
...
app/models/repository.rb
View file @
8587e3a3
...
...
@@ -35,6 +35,14 @@ class Repository
commits
end
def
find_branch
(
name
)
branches
.
find
{
|
branch
|
branch
.
name
==
name
}
end
def
find_tag
(
name
)
tags
.
find
{
|
tag
|
tag
.
name
==
name
}
end
def
add_branch
(
branch_name
,
ref
)
Rails
.
cache
.
delete
(
cache_key
(
:branch_names
))
...
...
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