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: add HostedGitInfo.fromManifest #288

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

Conversation

ljharb
Copy link

@ljharb ljharb commented Dec 16, 2024

This encapsulates the logic used in npm repo

Per Slack discussion. Once this is published and updated in the cli, I'll happily adapt the npm repo code to use this method.

The method will either return a HGI instance, a string URL, or null.

This encapsulates the logic used in `npm repo`
@ljharb ljharb requested a review from a team as a code owner December 16, 2024 23:38
@ljharb ljharb marked this pull request as draft December 17, 2024 00:25
@ljharb ljharb marked this pull request as ready for review December 17, 2024 00:53
lib/index.js Outdated Show resolved Hide resolved
@ljharb
Copy link
Author

ljharb commented Dec 17, 2024

Yay! When do you think this can go out in a semver-minor? (obv it'll still need CI to run)

@wraithgar
Copy link
Member

~/D/n/h/b/main (fromManifest|✚2) $ git diff
diff --git a/lib/index.js b/lib/index.js
index c5220a4..2a7100d 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -15,7 +15,7 @@ function unknownHostedUrl (url) {
       pathname,
     } = new URL(url)
 
-    if (!protocol || !hostname) {
+    if (!hostname) {
       return null
     }
 
diff --git a/test/github.js b/test/github.js
index 7d7739b..7429bd8 100644
--- a/test/github.js
+++ b/test/github.js
@@ -345,5 +345,13 @@ t.test('from manifest', t => {
   }
   t.throws(() => HostedGit.fromManifest(nonStringRepo))
 
+  const fileRepo = {
+    name: 'foo',
+    repository: {
+      url: 'file:///path/dot.git',
+    },
+  }
+  t.equal(HostedGit.fromManifest(fileRepo), null)
+

This implements my original suggestion

@ljharb
Copy link
Author

ljharb commented Jan 3, 2025

alrighty, updated

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