sakura-editor / changelog-sakura

changelog for sakura
MIT License
1 stars 3 forks source link

Ruby 2.5/Ruby 2.4 + github_changelog_generator の master で Octokit::NotFound のエラーになる #17

Open m-tmatma opened 5 years ago

m-tmatma commented 5 years ago

Ruby 2.5/Ruby 2.4 + github_changelog_generator の master で Octokit::NotFound のエラーになる

2020/5/4 追記

最新版では

https://ci.appveyor.com/project/sakuraeditor/changelog-sakura/builds/32427669

以下のエラーになります。

C:/Ruby25-x64/bin/github_changelog_generator: stack level too deep (SystemStackError)

オリジナルの問題

https://github.com/sakura-editor/changelog-sakura/issues/15#issuecomment-447329958

C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/octokit-4.13.0/lib/octokit/response/raise_error.rb:16:in `on_complete': GET https://api.github.com/repos/sakura-editor/sakura/compare/c1357c0cf2b5dcee5458d2e48f2b0b3130643db9...v2.2.0.0: 404 - No common ancestor between c1357c0cf2b5dcee5458d2e48f2b0b3130643db9 and v2.2.0.0. // See: https://developer.github.com/v3/repos/commits/#compare-two-commits (Octokit::NotFound)
Traceback (most recent call last):
        22: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/github_changelog_generator-1.15.0.pre.rc/lib/github_changelog_generator/octo_fetcher.rb:321:in `block (3 levels) in fetch_tag_shas_async'
        21: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/github_changelog_generator-1.15.0.pre.rc/lib/github_changelog_generator/octo_fetcher.rb:255:in `fetch_compare'
        20: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/github_changelog_generator-1.15.0.pre.rc/lib/github_changelog_generator/octo_fetcher.rb:397:in `check_github_response'
        19: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/retriable-3.1.2/lib/retriable.rb:56:in `retriable'
        18: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/retriable-3.1.2/lib/retriable.rb:56:in `times'
        17: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/retriable-3.1.2/lib/retriable.rb:61:in `block in retriable'
        16: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/github_changelog_generator-1.15.0.pre.rc/lib/github_changelog_generator/octo_fetcher.rb:398:in `block in check_github_response'
        15: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/github_changelog_generator-1.15.0.pre.rc/lib/github_changelog_generator/octo_fetcher.rb:255:in `block in fetch_compare'
        14: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/octokit-4.13.0/lib/octokit/client/commits.rb:198:in `compare'
        13: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/octokit-4.13.0/lib/octokit/connection.rb:19:in `get'
        12: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/octokit-4.13.0/lib/octokit/connection.rb:156:in `request'
        11: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/sawyer-0.8.1/lib/sawyer/agent.rb:94:in `call'
        10: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/faraday-0.15.4/lib/faraday/connection.rb:138:in `get'
         9: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/faraday-0.15.4/lib/faraday/connection.rb:387:in `run_request'
         8: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/faraday-0.15.4/lib/faraday/rack_builder.rb:143:in `build_response'
         7: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/faraday-http-cache-2.0.0/lib/faraday/http_cache.rb:115:in `call'
         6: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/faraday-http-cache-2.0.0/lib/faraday/http_cache.rb:142:in `call!'
         5: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/faraday-http-cache-2.0.0/lib/faraday/http_cache.rb:195:in `process'
         4: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/faraday-http-cache-2.0.0/lib/faraday/http_cache.rb:290:in `fetch'
         3: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/faraday-0.15.4/lib/faraday/response.rb:8:in `call'
         2: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/faraday-0.15.4/lib/faraday/response.rb:61:in `on_complete'
         1: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/faraday-0.15.4/lib/faraday/response.rb:9:in `block in call'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/octokit-4.13.0/lib/octokit/response/raise_error.rb:16:in `on_complete': GET https://api.github.com/repos/sakura-editor/sakura/compare/c1357c0cf2b5dcee5458d2e48f2b0b3130643db9...v2.3.2.0: 404 - No common ancestor between c1357c0cf2b5dcee5458d2e48f2b0b3130643db9 and v2.3.2.0. // See: https://developer.github.com/v3/repos/commits/#compare-two-commits (Octokit::NotFound)
m-tmatma commented 5 years ago

NG https://github.com/github-changelog-generator/github-changelog-generator/commit/5d7f18bc415e9a2c27769b7ea0adb9bc18b285c0 NG https://github.com/github-changelog-generator/github-changelog-generator/commit/a92b91336c5cb62b170abe2784916b7e998005f8

takke commented 5 years ago

少し調べてみました。

sakuraリポジトリの最古のコミット https://github.com/sakura-editor/sakura/commits/c1357c0cf2b5dcee5458d2e48f2b0b3130643db9 と master を比較する API を叩いて、No common ancestor と言われていますね。

該当する修正を探したところ、https://github.com/github-changelog-generator/github-changelog-generator/commit/372875f74838e5d7ab38bc337ec4333b540c13cd でした。

内容を深くは見ていませんが、取り急ぎ、

$ git checkout 372875f7

でエラーが発生し、

$  git checkout 372875f7~

では発生しないことを確認できました。

主なコマンド:

$ git clone git@github.com:github-changelog-generator/github-changelog-generator.git
$ cd github-changelog-generator
$ git checkout 372875f7~

※pp で止まるのでとりあえずコメントアウト
$ vim lib/github_changelog_generator/options.rb
$ git diff lib/github_changelog_generator/options.rb
diff --git a/lib/github_changelog_generator/options.rb b/lib/github_changelog_generator/options.rb
index 0578cbd..69a5a45 100644
--- a/lib/github_changelog_generator/options.rb
+++ b/lib/github_changelog_generator/options.rb
@@ -104,7 +104,7 @@ module GitHubChangelogGenerator
     def print_options
       return unless self[:verbose]
       Helper.log.info "Using these options:"
-      pp(censored_values)
+#      pp(censored_values)
       puts ""
     end

$ gem build github_changelog_generator && gem install github_changelog_generator-1.15.0.pre.rc.gem

>github_changelog_generator -u sakura-editor -p sakura
---> OK

$ git checkout 372875f7
$ gem build github_changelog_generator && gem install github_changelog_generator-1.15.0.pre.rc.gem

>github_changelog_generator -u sakura-editor -p sakura
---> NG
takke commented 5 years ago

sakuraリポジトリのどこからが common ancestor なのか探しました。

git の中身はあまり詳しくないんですが、cvs -> svn -> git と移行してきたリポジトリの cvs -> svn 部分で git の tree が壊れてる的なことでしょうか。

k-takata commented 5 years ago

d6ffc6d489ee0a7c4683d8f34d8c668915919263 は c1357c0cf2b5dcee5458d2e48f2b0b3130643db9 から始まっており、これは sakura-editor/sakura#60 で統合された installer のブランチですね。もともと別リポジトリだったので、共通先祖がなくて正しいです。

m-tmatma commented 5 years ago

Ruby 2.4 でも発生するのでタイトルを変えました。

m-tmatma commented 5 years ago

https://github.com/github-changelog-generator/github-changelog-generator/issues/695 でとりあえず現象発生の情報だけ投げときました。

m-tmatma commented 5 years ago

バグ報告したけど、他のチケットも放置されてるみたい。何ヶ月も前のチケットが、何のコメントもなくそのままになっていたりする。

takke commented 5 years ago

数ヶ月前に試していたものを放置していたのでメモだけ。

とりあえず下記のようにすると oldest_commit が任意のものになるのでエラーは発生しなくなる。

# lib/github_changelog_generator/octo_fetcher.rb

     def oldest_commit
       target_sha = '756ed7f5d6449d49df59c19d94820fc4f6b7748b'
       commits.each do |c|
         return c if c["sha"] == target_sha
       end

       commits.last
     end

oldest_commit を任意に設定できるようにすると、全コミットを取得する必要もなくなるので本事象以外にもメリットはあるので、そんな感じのオプションを追加するPRでも送ろうと思っていますがいつになるやら。

m-tmatma commented 4 years ago

コメント来ていたので https://github.com/github-changelog-generator/github-changelog-generator/issues/695#issuecomment-618382511

最新版でテストして返信返しておきました。 https://github.com/github-changelog-generator/github-changelog-generator/issues/695#issuecomment-619269927

m-tmatma commented 4 years ago

↑ に書きましたが、

https://ci.appveyor.com/project/sakuraeditor/changelog-sakura/builds/32427669

以下のエラーになりました。

C:/Ruby25-x64/bin/github_changelog_generator: stack level too deep (SystemStackError)

m-tmatma commented 4 years ago

追加でコメントした https://github.com/github-changelog-generator/github-changelog-generator/issues/695#issuecomment-619283363

発生当時に現象が発生する最古のバージョン で再実行したら処理が完了しなかった。

takke commented 4 years ago

stack level too deep (SystemStackError) についてですが、https://github.com/github-changelog-generator/github-changelog-generator/blob/9825c5e9778abd9026c156bd46e1053960df47c2/lib/github_changelog_generator/octo_fetcher.rb#L353 にある commits_in_tag というメソッドの再帰が深すぎて発生していることがわかりました。

再帰をループに変更してやろうかと思っていますが、ひとまず

return if shas.count > 500

のような条件で抜けるようにして強引に動かし、https://github.com/sakura-editor/sakura/pull/1232 の調査を進めています。

https://github.com/github-changelog-generator/github-changelog-generator/issues/695 に対しては元の問題は発生しなくなったのでいったんクローズして、別のIssueとして上げてあげたほうがいいかもしれません。

m-tmatma commented 4 years ago

github-changelog-generator/github-changelog-generator#695 に対しては元の問題は発生しなくなったのでいったんクローズして、別のIssueとして上げてあげたほうがいいかもしれません。

issue の登録お願いできますか?

takke commented 4 years ago

issue の登録お願いできますか?

https://github.com/github-changelog-generator/github-changelog-generator/issues/829 を登録しておきました。

そして、since-commit オプションを追加して、取得するコミット数を減らすことで回避できたので https://github.com/github-changelog-generator/github-changelog-generator/issues/830 を投げておきました。

先ほど試した感じだとこれくらいでした。取得する commit 数も減るんで多少速くなったはず。

コミットを重ねていくとまた発生するかもしれませんがそのときはいよいよ再帰をループに変更するしかないのかな。