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

feat(git-diff): add @d-zero/git-diff #35

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

yusasa16
Copy link

@yusasa16 yusasa16 commented May 16, 2024

gitのコミット間の差分を取得するツールgit-diffの追加

Copy link
Member

@YusukeHirao YusukeHirao left a comment

Choose a reason for hiding this comment

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

@yusasa16

テストファイルを作ってください。

Copy link
Member

Choose a reason for hiding this comment

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

@yusasa16 このファイルはpublish時に自動的に生成されるため、最初は不要です。ここでは削除しておいてください。

@@ -0,0 +1,22 @@
{
"name": "@d-zero/git-diff",
"version": "1.0.0",
Copy link
Member

Choose a reason for hiding this comment

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

@yusasa16

Suggested change
"version": "1.0.0",
"version": "1.0.0-alpha.0",

最初はアルファ版でマークしましょう。

import { execSync } from 'node:child_process';

const tag =
process.argv[2] || execSync('git describe --tags --abbrev=0').toString('utf8').trim();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
process.argv[2] || execSync('git describe --tags --abbrev=0').toString('utf8').trim();
process.argv[2] ?? execSync('git describe --tags --abbrev=0').toString('utf8').trim();

Copy link
Member

Choose a reason for hiding this comment

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

@yusasa16

論理値ではないものの代入なので || ではなく ?? を使いましょう。


const tag =
process.argv[2] || execSync('git describe --tags --abbrev=0').toString('utf8').trim();
const tag2 = process.argv[3] || 'HEAD';
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const tag2 = process.argv[3] || 'HEAD';
const tag2 = process.argv[3] ?? 'HEAD';

@yusasa16

論理値ではないものの代入なので || ではなく ?? を使いましょう。

const gitDiff = `git diff --name-only ${tag} ${tag2} --diff-filter=ACMR`;
const list = execSync(gitDiff).toString('utf8').trim();
// eslint-disable-next-line no-console
console.log(list);
Copy link
Member

Choose a reason for hiding this comment

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

@yusasa16

出力がどんなものになるのか、出力されたものの何を読んで、何を判断するのか、ドキュメントか何かに記載してほしいです。

Comment on lines +9 to +10
// eslint-disable-next-line no-console
console.log(list);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// eslint-disable-next-line no-console
console.log(list);
process.stdout.write(`${list}\n`);

@YusukeHirao YusukeHirao assigned yusasa16 and unassigned YusukeHirao May 16, 2024
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.

2 participants