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: support symbolic link git dir #1353

Closed

Conversation

mariodu
Copy link

@mariodu mariodu commented Nov 10, 2023

Related: #1351

Changes

  • when git dir is symbolic link, use fs.realpath find once as result

Copy link

changeset-bot bot commented Nov 10, 2023

⚠️ No Changeset found

Latest commit: 702043f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@iiroj
Copy link
Member

iiroj commented Nov 10, 2023

Thanks! Looks like some normalize-path is needed for Windows support.

Copy link
Member

@iiroj iiroj left a comment

Choose a reason for hiding this comment

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

You should run the linters configured in the repo to make sure ESLint is happy, and also generate the changeset file to describe your change. It can be done with npx changeset and then type in your description.

I would treat this as a patch-level fix instead of a feature. 👍

// If .git is a symbolic link, find realpath and use it,
// thought realpath is a directory, avoid infinite recursion.
if (stats.isSymbolicLink()) {
return fs.realpath(defaultDir);
Copy link
Member

Choose a reason for hiding this comment

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

This probably needs to be wrapped in normalizePath:

Suggested change
return fs.realpath(defaultDir);
return normalizePath(await fs.realpath(defaultDir))

@iiroj
Copy link
Member

iiroj commented Nov 11, 2023

On further testing, I'm closing this PR since we already support symlinks by using the fs.realPath here:

const defaultDir = normalizePath(await fs.realpath(path.join(gitDir, '.git')))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants