From d8289b83d55a17887c1984d55ff72df42a665843 Mon Sep 17 00:00:00 2001 From: Olle Jonsson Date: Fri, 2 Dec 2016 21:46:48 +0100 Subject: [PATCH 1/3] OctoFetcher: http_cache options conditional --- lib/github_changelog_generator/octo_fetcher.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/github_changelog_generator/octo_fetcher.rb b/lib/github_changelog_generator/octo_fetcher.rb index 66710c217..a3aecf8b9 100644 --- a/lib/github_changelog_generator/octo_fetcher.rb +++ b/lib/github_changelog_generator/octo_fetcher.rb @@ -29,10 +29,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) { "/tmp/github-changelog-http-cache" } + @cache_log = @options.fetch(:cache_log) { "/tmp/github-changelog-logger.log" } + init_cache + end @github_token = fetch_github_token @request_options = { per_page: PER_PAGE_NUMBER } From 7e3655d464ff988cc8486ebd83ce5cc85b84e7a6 Mon Sep 17 00:00:00 2001 From: Olle Jonsson Date: Fri, 2 Dec 2016 21:55:08 +0100 Subject: [PATCH 2/3] Locate cache directory using Dir.tmpdir --- lib/github_changelog_generator/octo_fetcher.rb | 5 +++-- lib/github_changelog_generator/parser.rb | 4 ++-- man/git-generate-changelog.1 | 6 +++--- man/git-generate-changelog.1.html | 6 +++--- man/git-generate-changelog.md | 4 ++-- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/github_changelog_generator/octo_fetcher.rb b/lib/github_changelog_generator/octo_fetcher.rb index a3aecf8b9..d05fcb214 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 @@ -30,8 +31,8 @@ def initialize(options = {}) @since = @options[:since] @http_cache = @options[:http_cache] if @http_cache - @cache_file = @options.fetch(:cache_file) { "/tmp/github-changelog-http-cache" } - @cache_log = @options.fetch(:cache_log) { "/tmp/github-changelog-logger.log" } + @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 diff --git a/lib/github_changelog_generator/parser.rb b/lib/github_changelog_generator/parser.rb index 5c8f8ebf5..17a2fb337 100755 --- a/lib/github_changelog_generator/parser.rb +++ b/lib/github_changelog_generator/parser.rb @@ -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| diff --git a/man/git-generate-changelog.1 b/man/git-generate-changelog.1 index 23edd6b46..faa961f51 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 fee2ffa8f..ad35a9224 100644 --- a/man/git-generate-changelog.1.html +++ b/man/git-generate-changelog.1.html @@ -246,11 +246,11 @@

OPTIONS

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

SEE ALSO

  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 463c680ff..6a77531da 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 From 201294027bdec00004fb44bd14fb1d96dcf40564 Mon Sep 17 00:00:00 2001 From: Olle Jonsson Date: Mon, 5 Dec 2016 23:24:07 +0100 Subject: [PATCH 3/3] Cache files options can not have defaults --- lib/github_changelog_generator/parser.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/github_changelog_generator/parser.rb b/lib/github_changelog_generator/parser.rb index 17a2fb337..0d828910c 100755 --- a/lib/github_changelog_generator/parser.rb +++ b/lib/github_changelog_generator/parser.rb @@ -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