Skip to content

mygit commit コマンドの実装#22

Merged
massan02 merged 22 commits intomainfrom
ulxsth/mygit-commit
Mar 28, 2025
Merged

mygit commit コマンドの実装#22
massan02 merged 22 commits intomainfrom
ulxsth/mygit-commit

Conversation

@ulxsth
Copy link
Contributor

@ulxsth ulxsth commented Mar 27, 2025

Details

以下のフォーマットで、コミット処理を受け付けます。

mygit commit -m <commit message>

前提

  • プロジェクトルートへの追加のみに対応しています。
  • .txt ファイルの追加のみを想定しています。
  • user.emailuser.name の反映には対応してません(固定値が挿入されてます)

既知のバグ

mygit commit 後、git status がバグります。おそらく何かしらの参照を壊しているものと推測。

治しました。エントリのmodeが10進数で格納されていたっぽい。

$ git status
fatal: malformed mode in tree entry

Debug

example フォルダを作り、以下のようにして初期化します。

mkdir example
cd example
git init
echo "hoge" > hoge.txt
git add .
git commit -m "hoge"

その後、mygit commit をテストします。
mygit add は未実装であるため、git add で代用してください。

echo "huga" > huga.txt
git add .
mygit commit -m "huga"

@massan02
Copy link
Contributor

node:fs:443
return binding.readFileUtf8(path, stringToFlags(options.flag));
^

Error: ENOENT: no such file or directory, open '/Users/murasakimasato/Documents/GitHub/git-intern-2025-term1/example/.git/refs/heads/main'
at Object.readFileSync (node:fs:443:20)
at getLatestCommitHash (file:///Users/murasakimasato/Documents/GitHub/git-intern-2025-term1/dist/commands/commit.js:74:27)
at Object.exec (file:///Users/murasakimasato/Documents/GitHub/git-intern-2025-term1/dist/commands/commit.js:39:25)
at mygit (file:///Users/murasakimasato/Documents/GitHub/git-intern-2025-term1/dist/mygit.js:22:21) {
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: '/Users/murasakimasato/Documents/GitHub/git-intern-2025-term1/example/.git/refs/heads/main'
}

Node.js v23.10.0

@massan02
Copy link
Contributor

git init後、ブランチ名を「master」から「main」に切り替えると成功

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