Skip to content
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

Upgrade git-stein to v0.5.0 #141

Merged
merged 4 commits into from
Apr 18, 2020
Merged

Upgrade git-stein to v0.5.0 #141

merged 4 commits into from
Apr 18, 2020

Conversation

sh5i
Copy link
Collaborator

@sh5i sh5i commented Mar 28, 2020

No description provided.

@sh5i sh5i requested a review from YoshikiHigo March 28, 2020 05:12
Copy link
Member

@YoshikiHigo YoshikiHigo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2つコメントしました.
ご確認ください.

@@ -25,46 +25,46 @@
public FinerGitRewriter(final FinerGitConfig config) {
this.config = config;
this.builder = new FinerJavaFileBuilder(config);
setConcurrent(config.isParallel());
setPathSensitive(true);
this.nthreads = config.isParallel() ? 0 : 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nthreadsは0か1を取る変数ですか?もしそうならboolean型の方がよくないでしょうか?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nthreadsは並列スレッド数で、1だと直列、2以上だとその数、0だとプロセッサ数−1を使う、という仕様になっています。FinerGitはスレッド数をパラメータとして受け取らないので、このようになっています。受け取るように変える手はあります。(これはわかりづらく、stein側のAPIを変えた方が良いかもしれません。良い案あれば欲しいです。)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FinerGitではparalellかどうかを指定するオプションがありますが,現状のオプションparalellを止めて,使用するスレッド数を直接指定するオプションに変更するのはどうでしょうか?
そのオプションが指定されなかった場合は,プロセッサ数-1を使うで良いと思います.(stein側でプロセッサ数が1の場合は考慮されていますか?)

steinも同じようにしてはどうでしょうか? 「0だとプロセッサ数-1を使う」は利用者からは直感的ではないですよね.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ご指摘の通りです。stein では、-p4 (--paralell=4) と指定したら4に、-pと指定したら0になるような仕様になっています。

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FinerGitConfig 変更しても大丈夫ですか?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

はい,よろしくお願いします.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

args4j では,上記のような,数字を取るが数字の省略もできる引数,というのは作れないような気がします(確認してもらえるとうれしいです).別オプションにしましょうか.例えば,-p --nthreads=3みたいな.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FinerGitでは,オプションを指定しない場合は「CPU数-1」のスレッド数で動き,オプションで数字が指定された場合にはその数のスレッドで動作する.
オプションのみ(数字なし)のような入力は受け付けない,でどうでしょうか?
こちらでFinerGitConfig書き換えてもいいんですが,Conflict起きますよね...

return builder.getFinerJavaModules(base, source);
protected List<FinerJavaModule> extractFinerModules(final Entry entry, final Context c) {
final String base = entry.directory + "/" + entry.name;
final String body = new String(source.readBlob(entry.id, c), StandardCharsets.UTF_8);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

パスの区切り文字が"/"決め打ちになっていますが,ここってjava.nio.Pathを使った方が安全じゃないでしょうか?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

このパスはGitリポジトリ中のファイルの位置を示すもので、実行環境のOSにおけるファイルシステムに依存していません(チェックアウトしてファイルシステム上に展開することなく扱いますので)。Gitにおいては"/"が唯一のパス区切り文字で、むしろ"\"をファイル名に含められたりします。よって、本来は、ファイルシステム依存性を気にする必要はないはずです。

ただし、このbaseは後にすぐPathに入れられてFinerJavaFileBuilderに渡ります。Pathの機能でディレクトリ名やファイル名を取り出したりするためです。

final JavaFileVisitor visitor = new JavaFileVisitor(Paths.get(path), this.config);

よって、結局はPathになるので、この時点でPathにしてしまっても差し支えはありません。その場合、FinerJavaFileBuilder#getFinerJavaModulesがPathを受けるようにするべきですか?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Windows環境でもちゃんと動くのであれば,このままで結構です.

@sh5i
Copy link
Collaborator Author

sh5i commented Mar 29, 2020

コメント返しました。

@YoshikiHigo
Copy link
Member

コメントしました.

@sh5i
Copy link
Collaborator Author

sh5i commented Apr 18, 2020

更新しました.

Copy link
Member

@YoshikiHigo YoshikiHigo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ありがとうございます,マージします.
スレッド数の指定方法は思うところがあるので別でPR投げます.

@YoshikiHigo YoshikiHigo merged commit b60ef57 into master Apr 18, 2020
@YoshikiHigo YoshikiHigo deleted the stein-0.5.0 branch April 18, 2020 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants