git-maintain 0.12.0 → 0.14.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/travis.rb DELETED
@@ -1,80 +0,0 @@
1
- module GitMaintain
2
- class TravisCI < CI
3
- TRAVIS_URL='https://api.travis-ci.com/'
4
-
5
- def initialize(repo)
6
- super(repo)
7
- @url = TRAVIS_URL
8
- end
9
-
10
- private
11
- def getState(sha1, resp)
12
- br = findBranch(sha1, resp)
13
- return "not found" if br == nil
14
-
15
- return br["state"]
16
- end
17
- def getLog(sha1, resp)
18
- br = findBranch(sha1, resp)
19
- raise("Travis build not found") if br == nil
20
- job_id = br["job_ids"].last().to_s()
21
- return getJson(@url, "travis_log_" + job_id, 'jobs/' + job_id + '/log', false)
22
- end
23
- def getTS(sha1, resp)
24
- br = findBranch(sha1, resp)
25
- raise("Travis build not found") if br == nil
26
- return br["started_at"]
27
- end
28
- def checkState(sha1, resp)
29
- return getState(sha1, resp) == "passed"
30
- end
31
-
32
- def getBrValidJson()
33
- return getJson(@url, :travis_br_valid, 'repos/' + @repo.remote_valid + '/branches')
34
- end
35
- def getBrStableJson()
36
- return getJson(@url, :travis_br_stable, 'repos/' + @repo.remote_stable + '/branches')
37
- end
38
- def findBranch(sha1, resp)
39
- log(:DEBUG_CI, "Looking for build for #{sha1}")
40
- resp["branches"].each(){|br|
41
- commit=resp["commits"].select(){|e| e["id"] == br["commit_id"]}.first()
42
- raise("Incomplete JSON received from Travis") if commit == nil
43
- log(:DEBUG_CI, "Found entry for sha #{commit["sha"]}")
44
- next if commit["sha"] != sha1
45
- return br
46
- }
47
- return nil
48
- end
49
-
50
- public
51
- def getValidState(br, sha1)
52
- return getState(sha1, getBrValidJson())
53
- end
54
- def checkValidState(br, sha1)
55
- return checkState(sha1, getBrValidJson())
56
- end
57
- def getValidLog(br, sha1)
58
- return getLog(sha1, getBrValidJson())
59
- end
60
- def getValidTS(br, sha1)
61
- return getTS(sha1, getBrValidJson())
62
- end
63
-
64
- def getStableState(br, sha1)
65
- return getState(sha1, getBrStableJson())
66
- end
67
- def checkStableState(br, sha1)
68
- return checkState(sha1, getBrStableJson())
69
- end
70
- def getStableLog(br, sha1)
71
- return getLog(sha1, getBrStableJson())
72
- end
73
- def getStableTS(br, sha1)
74
- return getTS(sha1, getBrStableJson())
75
- end
76
- def isErrored(br, status)
77
- return status == "failed" || status == "errored"
78
- end
79
- end
80
- end