[DRE-commits] [librarian-puppet] 28/153: Fix issue #239 - add access_token correctly to url's which are already having query parameters

Stig Sandbeck Mathisen ssm at debian.org
Wed Jun 1 20:30:36 UTC 2016


This is an automated email from the git hooks/post-receive script.

ssm pushed a commit to branch master
in repository librarian-puppet.

commit 8249d1126573d29df675aac519b4ae138144de0d
Author: Martin Sturm <msturm at ebay.com>
Date:   Wed Jul 16 16:27:09 2014 +0200

    Fix issue #239 - add access_token correctly to url's which are already having query parameters
---
 lib/librarian/puppet/source/githubtarball/repo.rb  | 2 ++
 test/librarian/puppet/source/githubtarball_test.rb | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/librarian/puppet/source/githubtarball/repo.rb b/lib/librarian/puppet/source/githubtarball/repo.rb
index 09a62c6..1aa8b08 100644
--- a/lib/librarian/puppet/source/githubtarball/repo.rb
+++ b/lib/librarian/puppet/source/githubtarball/repo.rb
@@ -106,6 +106,8 @@ module Librarian
           def add_api_token_to_url url
             if token_key_nil?
               debug { "#{TOKEN_KEY} environment value is empty or missing" }
+            elsif url.include? "?"
+              url << "&access_token=#{ENV[TOKEN_KEY]}"
             else
               url << "?access_token=#{ENV[TOKEN_KEY]}"
             end
diff --git a/test/librarian/puppet/source/githubtarball_test.rb b/test/librarian/puppet/source/githubtarball_test.rb
index 7180ca9..86cde7d 100644
--- a/test/librarian/puppet/source/githubtarball_test.rb
+++ b/test/librarian/puppet/source/githubtarball_test.rb
@@ -28,7 +28,7 @@ describe Librarian::Puppet::Source::GitHubTarball::Repo do
     let(:repo) { Librarian::Puppet::Source::GitHubTarball::Repo.new(source, "bar") }
     let(:headers) { {'User-Agent' => "librarian-puppet v#{Librarian::Puppet::VERSION}"} }
     let(:url) { "https://api.github.com/foo?page=1&per_page=100" }
-    let(:url_with_token) { "https://api.github.com/foo?page=1&per_page=100?access_token=bar" }
+    let(:url_with_token) { "https://api.github.com/foo?page=1&per_page=100&access_token=bar" }
     ENV['GITHUB_API_TOKEN'] = ''
 
     it "succeeds" do

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/librarian-puppet.git



More information about the Pkg-ruby-extras-commits mailing list