Skip to content

feat: add HostedGitInfo.fromManifest #288

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

Merged
merged 1 commit into from
Apr 14, 2025
Merged

Conversation

ljharb
Copy link
Contributor

@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
@ljharb
Copy link
Contributor 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
Contributor Author

ljharb commented Jan 3, 2025

alrighty, updated

@owlstronaut
Copy link

@ljharb @wraithgar this seems to have fallen off the radar. It looks good to me. Anything to add here?

@ljharb
Copy link
Contributor Author

ljharb commented Apr 11, 2025

@owlstronaut as far as i know it's ready to go, just hasn't been revisited since january 3rd.

@owlstronaut owlstronaut merged commit ef0865c into npm:main Apr 14, 2025
20 checks passed
@github-actions github-actions bot mentioned this pull request Apr 14, 2025
@ljharb ljharb deleted the fromManifest branch April 14, 2025 17:49
@ljharb
Copy link
Contributor Author

ljharb commented Apr 14, 2025

thanks!

owlstronaut pushed a commit that referenced this pull request Apr 14, 2025
🤖 I have created a release *beep* *boop*
---


##
[8.1.0](v8.0.2...v8.1.0)
(2025-04-14)
### Features
*
[`ef0865c`](ef0865c)
[#288](#288) add
`HostedGitInfo.fromManifest` (#288) (@ljharb)
### Chores
*
[`ac08fe8`](ac08fe8)
[#296](#296) bump
@npmcli/template-oss from 4.23.6 to 4.24.3 (#296) (@dependabot[bot],
@npm-cli-bot)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

3 participants