Class: Bitbucket
- Inherits:
-
Object
show all
- Includes:
- API
- Defined in:
- lib/bitbucket.rb
Constant Summary
collapse
- LIMIT =
1000.to_s
- HOOK_EXCLUSIONS =
['WSC','CM','YOMS']
Instance Attribute Summary
Attributes included from API
#api
Instance Method Summary
collapse
Methods included from API
#create_api, #parsed_response, #request
Constructor Details
Returns a new instance of Bitbucket.
Instance Method Details
#apply_restrictions ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/bitbucket.rb', line 41
def apply_restrictions
set_hook_status_on_all_projects(
"org.christiangalsterer.stash-filehooks-plugin:filesize-hook",
true,
{
"pattern-1"=>".*",
"size-1"=>"10485760",
"pattern-exclude-1"=>"",
"pattern-branches-1"=>""
}.to_json
)
set_hook_status_on_all_projects(
"org.christiangalsterer.stash-filehooks-plugin:filename-hook",
false,
{
"pattern"=>"\\.(h26.?|mp.?.?|avi|webm|flv|tar(\\..?.?.?)?|zip|7z|rar|exe|msi|rpm|deb)$",
"pattern-exclude"=>"",
"pattern-branches"=>""
}.to_json
)
set_master_branch_protected_on_all_projects
projects.detect {|p| p.key == 'TRAIN'}.move_all_repos_to_project('TOLD')
end
|
#projects ⇒ Object
11
12
13
|
# File 'lib/bitbucket.rb', line 11
def projects
@projects ||= Project.get_all(self)
end
|
#remove_hooks_on_exclusions ⇒ Object
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/bitbucket.rb', line 30
def remove_hooks_on_exclusions
projects.select {|p| HOOK_EXCLUSIONS.include? p.key }.each do |project|
[
'org.christiangalsterer.stash-filehooks-plugin:filesize-hook',
"org.christiangalsterer.stash-filehooks-plugin:filename-hook",
].each do |key|
project.set_hook_status(key, false)
end
end
end
|
#set_hook_status_on_all_projects(key, status, settings = nil) ⇒ Object
23
24
25
26
27
28
|
# File 'lib/bitbucket.rb', line 23
def set_hook_status_on_all_projects(key,status,settings=nil)
projects.map do |project|
next if HOOK_EXCLUSIONS.include?(project.key)
project.set_hook_status(key, status, settings)
end
end
|
#set_master_branch_protected_on_all_projects ⇒ Object
15
16
17
18
19
20
21
|
# File 'lib/bitbucket.rb', line 15
def set_master_branch_protected_on_all_projects
projects.map do |project|
project.repositories.map do |r|
r.set_master_branch_protected unless r.master_branch_protected?
end
end
end
|