git-maintain 0.11.0 → 0.13.0

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.
@@ -0,0 +1,179 @@
1
+ # Main module for git-maintain repository maintenance tool.
2
+ module GitMaintain
3
+ # CI adapter class for Travis CI integration.
4
+ class TravisCI < CI
5
+ # Base URL for Travis CI API.
6
+ TRAVIS_URL='https://api.travis-ci.com/'
7
+
8
+ # Initialize TravisCI adapter.
9
+ #
10
+ # @param repo [Repo] The Repo instance
11
+ def initialize(repo)
12
+ super(repo)
13
+ @url = TRAVIS_URL
14
+ end
15
+
16
+ private
17
+ # Get the Travis build status string for a specific commit SHA.
18
+ #
19
+ # @param sha1 [String] Commit SHA
20
+ # @param resp [Hash] API response payload containing branch builds
21
+ # @return [String] Build status string (e.g. 'passed', 'failed')
22
+ def getState(sha1, resp)
23
+ br = findBranch(sha1, resp)
24
+ return "not found" if br == nil
25
+
26
+ return br["state"]
27
+ end
28
+
29
+ # Fetch the build logs from Travis CI for a specific commit SHA.
30
+ #
31
+ # @param sha1 [String] Commit SHA
32
+ # @param resp [Hash] API response payload
33
+ # @return [String] Build log output text
34
+ # @raise [GitMaintainError] If no build is found for the commit
35
+ def getLog(sha1, resp)
36
+ br = findBranch(sha1, resp)
37
+ raise GitMaintainError.new("Travis build not found") if br == nil
38
+ job_id = br["job_ids"].last().to_s()
39
+ return getJson(@url, "travis_log_" + job_id, 'jobs/' + job_id + '/log', false)
40
+ end
41
+
42
+ # Get the Travis build timestamp for a specific commit SHA.
43
+ #
44
+ # @param sha1 [String] Commit SHA
45
+ # @param resp [Hash] API response payload
46
+ # @return [String] Build started-at timestamp string
47
+ # @raise [GitMaintainError] If no build is found for the commit
48
+ def getTS(sha1, resp)
49
+ br = findBranch(sha1, resp)
50
+ raise GitMaintainError.new("Travis build not found") if br == nil
51
+ return br["started_at"]
52
+ end
53
+
54
+ # Check if the build status string represents success.
55
+ #
56
+ # @param sha1 [String] Commit SHA
57
+ # @param resp [Hash] API response payload
58
+ # @return [Boolean] True if build passed
59
+ def checkState(sha1, resp)
60
+ return getState(sha1, resp) == "passed"
61
+ end
62
+
63
+ # Fetch validation branch builds JSON payload from Travis CI API.
64
+ #
65
+ # @return [Hash] JSON API response
66
+ # @raise [GitMaintainError] If API request fails
67
+ def getBrValidJson()
68
+ return getJson(@url, :travis_br_valid, 'repos/' + @repo.remote_valid + '/branches')
69
+ end
70
+
71
+ # Fetch stable branch builds JSON payload from Travis CI API.
72
+ #
73
+ # @return [Hash] JSON API response
74
+ # @raise [GitMaintainError] If API request fails
75
+ def getBrStableJson()
76
+ return getJson(@url, :travis_br_stable, 'repos/' + @repo.remote_stable + '/branches')
77
+ end
78
+
79
+ # Find the specific branch build matching the given commit SHA.
80
+ #
81
+ # @param sha1 [String] Commit SHA
82
+ # @param resp [Hash] API response branches payload
83
+ # @return [Hash, nil] Branch build dictionary, or nil if not found
84
+ # @raise [GitMaintainError] If API response is missing expected commit keys
85
+ def findBranch(sha1, resp)
86
+ log(:DEBUG_CI, "Looking for build for #{sha1}")
87
+ resp["branches"].each(){|br|
88
+ commit=resp["commits"].select(){|e| e["id"] == br["commit_id"]}.first()
89
+ raise GitMaintainError.new("Incomplete JSON received from Travis") if commit == nil
90
+ log(:DEBUG_CI, "Found entry for sha #{commit["sha"]}")
91
+ next if commit["sha"] != sha1
92
+ return br
93
+ }
94
+ return nil
95
+ end
96
+
97
+ public
98
+ # Retrieve the validation build state for a specific branch and commit.
99
+ #
100
+ # @param br [Branch] The Branch instance
101
+ # @param sha1 [String] Commit SHA
102
+ # @return [String] Build status string (e.g. 'passed')
103
+ def getValidState(br, sha1)
104
+ return getState(sha1, getBrValidJson())
105
+ end
106
+
107
+ # Check if the validation build is successful.
108
+ #
109
+ # @param br [Branch] The Branch instance
110
+ # @param sha1 [String] Commit SHA
111
+ # @return [Boolean] True if build passed
112
+ def checkValidState(br, sha1)
113
+ return checkState(sha1, getBrValidJson())
114
+ end
115
+
116
+ # Retrieve the validation build log.
117
+ #
118
+ # @param br [Branch] The Branch instance
119
+ # @param sha1 [String] Commit SHA
120
+ # @return [String] Build log output text
121
+ def getValidLog(br, sha1)
122
+ return getLog(sha1, getBrValidJson())
123
+ end
124
+
125
+ # Retrieve the validation build timestamp.
126
+ #
127
+ # @param br [Branch] The Branch instance
128
+ # @param sha1 [String] Commit SHA
129
+ # @return [String] Build timestamp
130
+ def getValidTS(br, sha1)
131
+ return getTS(sha1, getBrValidJson())
132
+ end
133
+
134
+ # Retrieve the stable build state for a specific branch and commit.
135
+ #
136
+ # @param br [Branch] The Branch instance
137
+ # @param sha1 [String] Commit SHA
138
+ # @return [String] Build status string (e.g. 'passed')
139
+ def getStableState(br, sha1)
140
+ return getState(sha1, getBrStableJson())
141
+ end
142
+
143
+ # Check if the stable build is successful.
144
+ #
145
+ # @param br [Branch] The Branch instance
146
+ # @param sha1 [String] Commit SHA
147
+ # @return [Boolean] True if build passed
148
+ def checkStableState(br, sha1)
149
+ return checkState(sha1, getBrStableJson())
150
+ end
151
+
152
+ # Retrieve the stable build log.
153
+ #
154
+ # @param br [Branch] The Branch instance
155
+ # @param sha1 [String] Commit SHA
156
+ # @return [String] Build log output text
157
+ def getStableLog(br, sha1)
158
+ return getLog(sha1, getBrStableJson())
159
+ end
160
+
161
+ # Retrieve the stable build timestamp.
162
+ #
163
+ # @param br [Branch] The Branch instance
164
+ # @param sha1 [String] Commit SHA
165
+ # @return [String] Build timestamp
166
+ def getStableTS(br, sha1)
167
+ return getTS(sha1, getBrStableJson())
168
+ end
169
+
170
+ # Check if the CI build status represents an error/failure.
171
+ #
172
+ # @param br [Branch] The Branch instance
173
+ # @param status [String] CI status string
174
+ # @return [Boolean] True if build errored or failed
175
+ def isErrored(br, status)
176
+ return status == "failed" || status == "errored"
177
+ end
178
+ end
179
+ end
@@ -0,0 +1,2 @@
1
+ require_relative 'git-maintain/error'
2
+ require_relative 'git-maintain/common'
metadata CHANGED
@@ -1,15 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-maintain
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicolas Morey-Chaisemartin
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-04-15 00:00:00.000000000 Z
10
+ date: 2026-09-09 00:00:00.000000000 Z
12
11
  dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: cli_class_tool
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: 0.4.0
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: 0.4.0
13
26
  - !ruby/object:Gem::Dependency
14
27
  name: octokit
15
28
  requirement: !ruby/object:Gem::Requirement
@@ -38,19 +51,23 @@ files:
38
51
  - README.md
39
52
  - bin/git-maintain
40
53
  - git-maintain-completion.sh
41
- - lib/addons/RDMACore.rb
42
- - lib/addons/git-maintain.rb
43
- - lib/azure.rb
44
- - lib/branch.rb
45
- - lib/ci.rb
46
- - lib/common.rb
47
- - lib/repo.rb
48
- - lib/travis.rb
54
+ - lib/git-maintain.rb
55
+ - lib/git-maintain/addons/RDMACore.rb
56
+ - lib/git-maintain/addons/git-maintain.rb
57
+ - lib/git-maintain/addons/healthd.rb
58
+ - lib/git-maintain/addons/hpc-testing.rb
59
+ - lib/git-maintain/azure.rb
60
+ - lib/git-maintain/branch.rb
61
+ - lib/git-maintain/branch_iterator.rb
62
+ - lib/git-maintain/ci.rb
63
+ - lib/git-maintain/common.rb
64
+ - lib/git-maintain/error.rb
65
+ - lib/git-maintain/repo.rb
66
+ - lib/git-maintain/travis.rb
49
67
  homepage: https://github.com/nmorey/git-maintain
50
68
  licenses:
51
69
  - GPL-3.0
52
70
  metadata: {}
53
- post_install_message:
54
71
  rdoc_options: []
55
72
  require_paths:
56
73
  - lib
@@ -65,8 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
82
  - !ruby/object:Gem::Version
66
83
  version: '0'
67
84
  requirements: []
68
- rubygems_version: 3.2.33
69
- signing_key:
85
+ rubygems_version: 4.0.16
70
86
  specification_version: 4
71
87
  summary: Your ultimate script for maintaining stable branches and releasing your project.
72
88
  test_files: []
data/lib/azure.rb DELETED
@@ -1,98 +0,0 @@
1
- module GitMaintain
2
- class AzureCI < CI
3
- AZURE_URL='https://dev.azure.com/'
4
-
5
- def initialize(repo, stable='', valid='')
6
- super(repo)
7
- @url = AZURE_URL
8
- @stable_org=stable
9
- @valid_org=valid
10
- end
11
-
12
- private
13
- def getState(sha1, resp)
14
- br = findBranch(sha1, resp)
15
- return "not found" if br == nil
16
- return "started" if br["result"] == nil
17
- return br["result"].to_s()
18
- end
19
- def getLog(sha1, resp)
20
- str=""
21
- # br = findBranch(sha1, resp)
22
- # raise("Travis build not found") if br == nil
23
- # job_id = br["id"].to_s()
24
- # logs= getJson(@url, "azure_log_list" + job_id,
25
- # @repo.name + "/_apis/build/builds/#{job_id}/logs?api-version=5.1")
26
- # 1.upto(logs["count"]) { |x|
27
- # log(:DEBUG_CI, "Downloading log file #{x}/#{logs["count"]}")
28
- # nzstr = getJson(@url, "azure_log_" + job_id + '_' + x.to_s(),
29
- # @repo.name + "/_apis/build/builds/#{job_id}/logs/#{x}?api-version=5.1", false)
30
- # # This is zipped. We need to extract it
31
- # }
32
- return str
33
- end
34
- def getTS(sha1, resp)
35
- br = findBranch(sha1, resp)
36
- raise("Travis build not found") if br == nil
37
- return br["startTime"]
38
- end
39
- def checkState(sha1, resp)
40
- st = getState(sha1, resp)
41
- return st == "passed" || st == "succeeded"
42
- end
43
-
44
- def getBrValidJson()
45
- raise("Validation organisation not provided") if @valid_org == ''
46
- return getJson(@url + @valid_org + '/',
47
- :azure_br_valid, @repo.name + '/_apis/build/builds?api-version=5.1')
48
- end
49
- def getBrStableJson()
50
- raise("Stable organisation not provided") if @stable_org == ''
51
- return getJson(@url + @stable_org + '/',
52
- :azure_br_stable, @repo.name + '/_apis/build/builds?api-version=5.1')
53
- end
54
- def findBranch(sha1, resp)
55
- log(:DEBUG_CI, "Looking for build for #{sha1}")
56
- resp["value"].each(){|br|
57
- commit= br["sourceVersion"]
58
- raise("Incomplete JSON received from Travis") if commit == nil
59
- log(:DEBUG_CI, "Found entry for sha #{commit}")
60
- next if commit != sha1
61
- return br
62
- }
63
- return nil
64
- end
65
-
66
- public
67
- def getValidState(br, sha1)
68
- return getState(sha1, getBrValidJson())
69
- end
70
- def checkValidState(br, sha1)
71
- return checkState(sha1, getBrValidJson())
72
- end
73
- def getValidLog(br, sha1)
74
- return getLog(sha1, getBrValidJson())
75
- end
76
- def getValidTS(br, sha1)
77
- return getTS(sha1, getBrValidJson())
78
- end
79
-
80
- def getStableState(br, sha1)
81
- return getState(sha1, getBrStableJson())
82
- end
83
- def checkStableState(br, sha1)
84
- return checkState(sha1, getBrStableJson())
85
- end
86
- def getStableLog(br, sha1)
87
- return getLog(sha1, getBrStableJson())
88
- end
89
- def getStableTS(br, sha1)
90
- return getTS(sha1, getBrStableJson())
91
- end
92
- def isErrored(br, status)
93
- # https://docs.microsoft.com/en-us/rest/api/azure/devops/build/builds/list?
94
- # view=azure-devops-rest-5.1#buildresult
95
- return status == "failed"
96
- end
97
- end
98
- end