diff --git a/lib/github_changelog_generator/octo_fetcher.rb b/lib/github_changelog_generator/octo_fetcher.rb index 66710c2..d05fcb2 100644 --- a/lib/github_changelog_generator/octo_fetcher.rb +++ b/lib/github_changelog_generator/octo_fetcher.rb @@ -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 } diff --git a/lib/github_changelog_generator/parser.rb b/lib/github_changelog_generator/parser.rb index 5c8f8eb..0d82891 100755 --- a/lib/github_changelog_generator/parser.rb +++ b/lib/github_changelog_generator/parser.rb @@ -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 diff --git a/man/git-generate-changelog.1 b/man/git-generate-changelog.1 index 23edd6b..faa961f 100644 --- a/man/git-generate-changelog.1 +++ b/man/git-generate-changelog.1 @@ -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 diff --git a/man/git-generate-changelog.1.html b/man/git-generate-changelog.1.html index fee2ffa..ad35a92 100644 --- a/man/git-generate-changelog.1.html +++ b/man/git-generate-changelog.1.html @@ -246,11 +246,11 @@

--[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

@@ -281,7 +281,7 @@
  1. -
  2. November 2016
  3. +
  4. December 2016
  5. git-generate-changelog(1)
diff --git a/man/git-generate-changelog.md b/man/git-generate-changelog.md index 463c680..6a77531 100644 --- a/man/git-generate-changelog.md +++ b/man/git-generate-changelog.md @@ -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