forked from Ermlab/nxt-gitlab
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreset-hooks.coffee
More file actions
31 lines (25 loc) · 893 Bytes
/
reset-hooks.coffee
File metadata and controls
31 lines (25 loc) · 893 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env coffee
# clear terminal
process.stdout.write '\u001B[2J\u001B[0;0f'
Gitlab = require('..')
credentials = require './credentials'
gitlab = new Gitlab
url: credentials.url
token: credentials.token
gitlab.projects.all (projects) ->
for _project in projects
do ->
project = _project
gitlab.projects.hooks.list project.id, (hooks) ->
url = "#{credentials.service_hook_base}#{project.path_with_namespace}"
if hooks.length > 1
console.log "#{url} too much hooks"
else if hooks.length is 1
for hook in hooks
if hook.url != url
gitlab.projects.hooks.remove project.id, hook.id, (ret) ->
console.log ret
console.log "#{url} is already OK"
else
gitlab.projects.hooks.add project.id, url, ->
console.log "#{url} has been added"