Create temporary cache files in Dir.tmpdir (#459)
* OctoFetcher: http_cache options conditional * Locate cache directory using Dir.tmpdir * Cache files options can not have defaults
This commit is contained in:
parent
17702543ef
commit
8d74965019
|
@ -1,4 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
require "tmpdir"
|
||||
require "retriable"
|
||||
module GitHubChangelogGenerator
|
||||
# A Fetcher responsible for all requests to GitHub and all basic manipulation with related data
|
||||
|
@ -29,10 +30,11 @@ module GitHubChangelogGenerator
|
|||
@project = @options[:project]
|
||||
@since = @options[:since]
|
||||
@http_cache = @options[:http_cache]
|
||||
@cache_file = @options.fetch(:cache_file, "/tmp/github-changelog-http-cache") if @http_cache
|
||||
@cache_log = @options.fetch(:cache_log, "/tmp/github-changelog-logger.log") if @http_cache
|
||||
init_cache if @http_cache
|
||||
|
||||
if @http_cache
|
||||
@cache_file = @options.fetch(:cache_file) { File.join(Dir.tmpdir, "github-changelog-http-cache") }
|
||||
@cache_log = @options.fetch(:cache_log) { File.join(Dir.tmpdir, "github-changelog-logger.log") }
|
||||
init_cache
|
||||
end
|
||||
@github_token = fetch_github_token
|
||||
|
||||
@request_options = { per_page: PER_PAGE_NUMBER }
|
||||
|
|
|
@ -167,10 +167,10 @@ module GitHubChangelogGenerator
|
|||
opts.on("--[no-]http-cache", "Use HTTP Cache to cache Github API requests (useful for large repos) Default is true.") do |http_cache|
|
||||
options[:http_cache] = http_cache
|
||||
end
|
||||
opts.on("--cache-file [CACHE-FILE]", "Filename to use for cache. Default is /tmp/github-changelog-http-cache") do |cache_file|
|
||||
opts.on("--cache-file [CACHE-FILE]", "Filename to use for cache. Default is github-changelog-http-cache in a temporary directory.") do |cache_file|
|
||||
options[:cache_file] = cache_file
|
||||
end
|
||||
opts.on("--cache-log [CACHE-LOG]", "Filename to use for cache log. Default is /tmp/github-changelog-logger.log") do |cache_log|
|
||||
opts.on("--cache-log [CACHE-LOG]", "Filename to use for cache log. Default is github-changelog-logger.log in a temporary directory.") do |cache_log|
|
||||
options[:cache_log] = cache_log
|
||||
end
|
||||
opts.on("--[no-]verbose", "Run verbosely. Default is true") do |v|
|
||||
|
@ -218,9 +218,7 @@ module GitHubChangelogGenerator
|
|||
bug_prefix: "**Fixed bugs:**",
|
||||
enhancement_prefix: "**Implemented enhancements:**",
|
||||
git_remote: "origin",
|
||||
http_cache: true,
|
||||
cache_file: "/tmp/github-changelog-http-cache",
|
||||
cache_log: "/tmp/github-changelog-logger.log"
|
||||
http_cache: true
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
.\" generated with Ronn/v0.7.3
|
||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||
.
|
||||
.TH "GIT\-GENERATE\-CHANGELOG" "1" "November 2016" "" ""
|
||||
.TH "GIT\-GENERATE\-CHANGELOG" "1" "December 2016" "" ""
|
||||
.
|
||||
.SH "NAME"
|
||||
\fBgit\-generate\-changelog\fR \- Generate changelog from github
|
||||
|
@ -256,13 +256,13 @@ Use HTTP Cache to cache Github API requests (useful for large repos) Default is
|
|||
\-\-[no\-]cache\-file [CACHE\-FILE]
|
||||
.
|
||||
.P
|
||||
Filename to use for cache\. Default is /tmp/github\-changelog\-http\-cache
|
||||
Filename to use for cache\. Default is github\-changelog\-http\-cache in a temporary directory\.
|
||||
.
|
||||
.P
|
||||
\-\-cache\-log [CACHE\-LOG]
|
||||
.
|
||||
.P
|
||||
Filename to use for cache log\. Default is /tmp/github\-changelog\-logger\.log
|
||||
Filename to use for cache log\. Default is github\-changelog\-logger\.log in a temporary directory\.
|
||||
.
|
||||
.P
|
||||
\-\-[no\-]verbose
|
||||
|
|
|
@ -246,11 +246,11 @@
|
|||
|
||||
<p> --[no-]cache-file [CACHE-FILE]</p>
|
||||
|
||||
<p> Filename to use for cache. Default is /tmp/github-changelog-http-cache</p>
|
||||
<p> Filename to use for cache. Default is github-changelog-http-cache in a temporary directory.</p>
|
||||
|
||||
<p> --cache-log [CACHE-LOG]</p>
|
||||
|
||||
<p> Filename to use for cache log. Default is /tmp/github-changelog-logger.log</p>
|
||||
<p> Filename to use for cache log. Default is github-changelog-logger.log in a temporary directory.</p>
|
||||
|
||||
<p> --[no-]verbose</p>
|
||||
|
||||
|
@ -281,7 +281,7 @@
|
|||
|
||||
<ol class='man-decor man-foot man foot'>
|
||||
<li class='tl'></li>
|
||||
<li class='tc'>November 2016</li>
|
||||
<li class='tc'>December 2016</li>
|
||||
<li class='tr'>git-generate-changelog(1)</li>
|
||||
</ol>
|
||||
|
||||
|
|
|
@ -173,11 +173,11 @@ Automatically generate change log from your tags, issues, labels and pull reques
|
|||
|
||||
--[no-]cache-file [CACHE-FILE]
|
||||
|
||||
Filename to use for cache. Default is /tmp/github-changelog-http-cache
|
||||
Filename to use for cache. Default is github-changelog-http-cache in a temporary directory.
|
||||
|
||||
--cache-log [CACHE-LOG]
|
||||
|
||||
Filename to use for cache log. Default is /tmp/github-changelog-logger.log
|
||||
Filename to use for cache log. Default is github-changelog-logger.log in a temporary directory.
|
||||
|
||||
--[no-]verbose
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user