-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
metanorma/metanorma#202 respect HTTP[S]|SOCKS_PROXY env vars during g…
…it clone
- Loading branch information
Showing
3 changed files
with
28 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
require "git" | ||
|
||
module Fontist | ||
module Utils | ||
class Git | ||
def self.clone(url, path, opts) | ||
http_proxy = ENV["SOCKS_PROXY"] || ENV["HTTP_PROXY"] | ||
https_proxy = ENV["SOCKS_PROXY"] || ENV["HTTPS_PROXY"] | ||
|
||
if http_proxy || https_proxy | ||
git = Git.init(path.to_s) | ||
git.config('http.proxy', http_proxy) if http_proxy # NOTE what if user move out of proxy | ||
git.config('https.proxy', https_proxy) if https_proxy | ||
git.add_remote('origin', url) | ||
git.fetch | ||
git.checkout("master") # FIXME after https://github.com/ruby-git/ruby-git/pull/532 | ||
else | ||
Git.clone(url, path, opts) | ||
end | ||
end | ||
end | ||
end | ||
end |