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
1
Merge Requests
1
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
nexedi
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
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
12 deletions
+36
-12
app/controllers/projects/branches_controller.rb
app/controllers/projects/branches_controller.rb
+8
-4
app/controllers/projects/tags_controller.rb
app/controllers/projects/tags_controller.rb
+9
-5
app/models/event.rb
app/models/event.rb
+11
-3
app/models/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
...
@@ -12,16 +12,20 @@ class Projects::BranchesController < Projects::ApplicationController
end
end
def
create
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
)
redirect_to
project_branches_path
(
@project
)
end
end
def
destroy
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
)
if
branch
&&
@repository
.
rm_branch
(
branch
.
name
)
Event
.
create_r
m_ref
(
@project
,
current_user
,
branch
)
Event
.
create_r
ef_event
(
@project
,
current_user
,
branch
,
'rm'
)
end
end
respond_to
do
|
format
|
respond_to
do
|
format
|
...
...
app/controllers/projects/tags_controller.rb
View file @
8587e3a3
...
@@ -8,20 +8,24 @@ class Projects::TagsController < Projects::ApplicationController
...
@@ -8,20 +8,24 @@ class Projects::TagsController < Projects::ApplicationController
before_filter
:authorize_admin_project!
,
only:
[
:destroy
]
before_filter
:authorize_admin_project!
,
only:
[
:destroy
]
def
index
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
end
def
create
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
)
redirect_to
project_tags_path
(
@project
)
end
end
def
destroy
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
)
if
tag
&&
@repository
.
rm_tag
(
tag
.
name
)
Event
.
create_r
m_ref
(
@project
,
current_user
,
tag
,
'refs/tags'
)
Event
.
create_r
ef_event
(
@project
,
current_user
,
tag
,
'rm'
,
'refs/tags'
)
end
end
respond_to
do
|
format
|
respond_to
do
|
format
|
...
...
app/models/event.rb
View file @
8587e3a3
...
@@ -55,14 +55,22 @@ class Event < ActiveRecord::Base
...
@@ -55,14 +55,22 @@ class Event < ActiveRecord::Base
end
end
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
(
Event
.
create
(
project:
project
,
project:
project
,
action:
Event
::
PUSHED
,
action:
Event
::
PUSHED
,
data:
{
data:
{
ref:
"
#{
prefix
}
/
#{
ref
.
name
}
"
,
ref:
"
#{
prefix
}
/
#{
ref
.
name
}
"
,
before:
ref
.
commit
.
id
,
before:
before
,
after:
'00000000'
after:
after
},
},
author_id:
user
.
id
author_id:
user
.
id
)
)
...
...
app/models/repository.rb
View file @
8587e3a3
...
@@ -35,6 +35,14 @@ class Repository
...
@@ -35,6 +35,14 @@ class Repository
commits
commits
end
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
)
def
add_branch
(
branch_name
,
ref
)
Rails
.
cache
.
delete
(
cache_key
(
:branch_names
))
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