Skip to content

feat: add HostedGitInfo.fromManifest - #288

Merged
owlstronaut merged 1 commit into
npm:mainfrom
ljharb:fromManifest
Apr 14, 2025
Merged

feat: add HostedGitInfo.fromManifest#288
owlstronaut merged 1 commit into
npm:mainfrom
ljharb:fromManifest

Conversation

@ljharb

@ljharb ljharb commented Dec 16, 2024

Copy link
Copy Markdown
Contributor

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
Comment thread lib/index.js Outdated
@ljharb

ljharb commented Dec 17, 2024

Copy link
Copy Markdown
Contributor Author

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

@wraithgar

Copy link
Copy Markdown
Contributor
~/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

ljharb commented Jan 3, 2025

Copy link
Copy Markdown
Contributor Author

alrighty, updated

@owlstronaut

Copy link
Copy Markdown

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

@ljharb

ljharb commented Apr 11, 2025

Copy link
Copy Markdown
Contributor Author

@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
@github-actions github-actions Bot mentioned this pull request Apr 14, 2025
@ljharb
ljharb deleted the fromManifest branch April 14, 2025 17:49
@ljharb

ljharb commented Apr 14, 2025

Copy link
Copy Markdown
Contributor Author

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