This is an automated email from the ASF dual-hosted git repository.
sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git
The following commit(s) were added to refs/heads/master by this push:
new f4ce20d Allow direct get of file
f4ce20d is described below
commit f4ce20d4937cbbb17e9aa1969fc39160a72ba056
Author: Sebb <[email protected]>
AuthorDate: Mon Mar 8 17:29:53 2021 +0000
Allow direct get of file
---
lib/whimsy/asf/git.rb | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/lib/whimsy/asf/git.rb b/lib/whimsy/asf/git.rb
index 517e721..eaf9c9b 100644
--- a/lib/whimsy/asf/git.rb
+++ b/lib/whimsy/asf/git.rb
@@ -1,4 +1,5 @@
require 'open3'
+require 'net/http'
module ASF
@@ -15,18 +16,24 @@ module ASF
# path to the deployment branch on GitHub.
INFRA_PUPPET = '/apache/infrastructure-puppet/deployment/'
+ # get a file live from github, e.g. '/apache/petri/master/info.yaml'
+ # returns body
+ def self.github(file, etag = nil)
+ http = Net::HTTP.new(GITHUB_HOST, 443)
+ http.use_ssl = true
+ return http.request(Net::HTTP::Get.new(file)).body
+ end
+
# get a file live from infrastructure puppet (e.g. 'data/common.yaml')
# issues a HTTP GET request, so may be slow and may fail. For applications
# that require faster and more dependable access,
# <tt>ASF::Git.find('infrastructure-puppet')</tt> may be used to get
# access to a clone that is updated every 10 minutes.
def self.infra_puppet(file)
- file = INFRA_PUPPET + file
- http = Net::HTTP.new(GITHUB_HOST, 443)
- http.use_ssl = true
- http.request(Net::HTTP::Get.new(file)).body
+ self.github(INFRA_PUPPET + file)
end
+
# path to <tt>repository.yml</tt> in the source.
REPOSITORY = File.expand_path('../../../repository.yml', __dir__)
@@ -105,3 +112,9 @@ module ASF
end
end
+
+if $0 == __FILE__
+ require 'net/http'
+ puts ASF::Git.github('/apache/petri/master/info.yaml')
+ puts ASF::Git.infra_puppet('data/common.yaml')
+end
\ No newline at end of file