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

Add Windows Hardlink & Symbolic Link Support #401

Merged
merged 4 commits into from
Oct 27, 2024

Conversation

walnuts1018
Copy link
Contributor

@walnuts1018 walnuts1018 commented Oct 26, 2024

Description

Resolved an issue where GHQ_ROOT did not work correctly on Windows when it was a symbolic link or junction. (fix #402 )

Issue

  • When GHQ_ROOT is a symbolic link, the ghq get command results in the error: The system cannot find the path specified.
  • If GHQ_ROOT is a symbolic link or junction, the ghq list command does not return a list of repositories.

Cause

  • On Windows, filepath.EvalSymlinks() does not recognize symbolic links and junctions.

Suggestion

  • On Windows, change the implementation to use os.Readlink() instead of filepath.EvalSymlinks() to follow links.
    • os.Readlink() can handle symbolic links and junctions on Windows.

Japanese

説明

Windowsにおいて、GHQ_ROOTがシンボリックリンクもしくはジャンクションである場合に正しく動作しない問題を解決しました。

問題

  • GHQ_ROOTがシンボリックリンクであった場合、ghq getコマンド実行時にThe system cannot find the path specified.というエラーが出る
  • GHQ_ROOTがシンボリックリンクやジャンクションであった場合、ghq listコマンドを実行しても、リポジトリ一覧が返ってこない

原因

  • Windowsでは、filepath.EvalSymlinks()がシンボリックリンクやジャンクションを認識しないため。

提案

  • Windowsの場合、filepath.EvalSymlinks()ではなく、os.Readlink()を使ってリンクを辿る実装に変更する
    • os.Readlink()は、Windowsのシンボリックリンクとジャンクションを扱うことが可能

Signed-off-by: walnuts1018 <[email protected]>
Signed-off-by: walnuts1018 <[email protected]>
Signed-off-by: walnuts1018 <[email protected]>
@Songmu Songmu merged commit c9e0c4e into x-motemen:master Oct 27, 2024
4 checks passed
@github-actions github-actions bot mentioned this pull request Oct 27, 2024
@Songmu
Copy link
Member

Songmu commented Oct 27, 2024

Thank you! Merged and released as v1.6.3.

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.

Support Windows Hardlink & Symbolic Link
2 participants