summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Niels Ole Salscheider <olesalscheider@exherbo.org> 2017-06-17 21:48:19 +0200
committerAvatar Niels Ole Salscheider <olesalscheider@exherbo.org> 2017-06-18 14:21:43 +0200
commit0cbf6d1dc3bfd0bff9f36c2b812a0c4d72f09c9e (patch)
tree0793cb07dc02c8931b4b30a2446113ecbe109e3f
parent15ab8ce9cd51931460c2f55cdbb3352178dacb75 (diff)
downloadinfra-scripts-0cbf6d1dc3bfd0bff9f36c2b812a0c4d72f09c9e.tar.gz
infra-scripts-0cbf6d1dc3bfd0bff9f36c2b812a0c4d72f09c9e.tar.xz
Add script to figure out which commits to build
-rw-r--r--continuous-integration/gitlab/commits_to_build.rb41
1 files changed, 41 insertions, 0 deletions
diff --git a/continuous-integration/gitlab/commits_to_build.rb b/continuous-integration/gitlab/commits_to_build.rb
new file mode 100644
index 0000000..9dc419a
--- /dev/null
+++ b/continuous-integration/gitlab/commits_to_build.rb
@@ -0,0 +1,41 @@
+#!/usr/bin/env ruby
+
+require 'gitlab'
+
+def get_ids(project_id, sha)
+ to_visit = [sha]
+ all_commits = []
+
+ while ( current_sha = to_visit.shift() )
+ commit = Gitlab.commit(project_id, current_sha)
+ if current_sha == sha || commit.status.nil?
+ all_commits << current_sha
+ commit.parent_ids.each { |c| to_visit << c }
+ end
+ end
+ return all_commits
+end
+
+project_id = nil
+sha = nil
+endpoint = nil
+token = nil
+while ( arg = ARGV.shift() )
+ case ( arg )
+ when /^--project-id(?:=(.+))?$/
+ project_id = $1 || ARGV.shift()
+ when /^--sha(?:=(.+))?$/
+ sha = $1 || ARGV.shift()
+ when /^--endpoint(?:=(.+))?$/
+ endpoint = $1 || ARGV.shift()
+ when /^--token(?:=(.+))?$/
+ token = $1 || ARGV.shift()
+ end
+end
+
+Gitlab.endpoint = endpoint
+Gitlab.private_token = token
+
+returned_ids = get_ids(project_id, sha)
+puts returned_ids * "\n"
+