Skip to content

Create temporary cache files in Dir.tmpdir #459

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions lib/github_changelog_generator/octo_fetcher.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -29,10 +30,11 @@ def initialize(options = {})
@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 }
Expand Down
8 changes: 3 additions & 5 deletions lib/github_changelog_generator/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@ def self.setup_parser(options)
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|
Expand Down Expand Up @@ -218,9 +218,7 @@ def self.default_options
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

Expand Down
6 changes: 3 additions & 3 deletions man/git-generate-changelog.1
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions man/git-generate-changelog.1.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/git-generate-changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down