Skip to content

Commit 5159877

Browse files
committed
* feat: Support Sourcehut
1 parent 0d3cf8b commit 5159877

File tree

5 files changed

+44
-12
lines changed

5 files changed

+44
-12
lines changed

node_modules/hosted-git-info/git-host-info.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,36 @@ gitHosts.gist = Object.assign({}, defaults, {
139139
}
140140
})
141141

142+
gitHosts.sourcehut = Object.assign({}, defaults, {
143+
protocols: ['git+ssh:', 'https:'],
144+
domain: 'git.sr.ht',
145+
treepath: 'tree',
146+
browsefiletemplate: ({ domain, user, project, committish, treepath, path, fragment, hashformat }) => `https://${domain}/${user}/${project}/${treepath}/${maybeEncode(committish || 'main')}/${path}${maybeJoin('#', hashformat(fragment || ''))}`,
147+
filetemplate: ({ domain, user, project, committish, path }) => `https://${domain}/${user}/${project}/blob/${maybeEncode(committish) || 'main'}/${path}`,
148+
httpstemplate: ({ domain, user, project, committish }) => `https://${domain}/${user}/${project}.git${maybeJoin('#', committish)}`,
149+
tarballtemplate: ({ domain, user, project, committish }) => `https://${domain}/${user}/${project}/archive/${maybeEncode(committish) || 'main'}.tar.gz`,
150+
bugstemplate: ({ domain, user, project }) => `https://todo.sr.ht/${user}/${project}`,
151+
docstemplate: ({ domain, user, project, treepath, committish }) => `https://${domain}/${user}/${project}${maybeJoin('/', treepath, '/', maybeEncode(committish))}#readme`,
152+
extract: (url) => {
153+
let [, user, project, aux] = url.pathname.split('/', 4)
154+
155+
// tarball url
156+
if (['archive'].includes(aux)) {
157+
return
158+
}
159+
160+
if (project && project.endsWith('.git')) {
161+
project = project.slice(0, -4)
162+
}
163+
164+
if (!user || !project) {
165+
return
166+
}
167+
168+
return { user, project, committish: url.hash.slice(1) }
169+
}
170+
})
171+
142172
const names = Object.keys(gitHosts)
143173
gitHosts.byShortcut = {}
144174
gitHosts.byDomain = {}

node_modules/hosted-git-info/package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hosted-git-info",
3-
"version": "4.0.2",
3+
"version": "4.1.0",
44
"description": "Provides metadata and conversions from repository urls for GitHub, Bitbucket and GitLab",
55
"main": "index.js",
66
"repository": {
@@ -34,7 +34,7 @@
3434
"devDependencies": {
3535
"standard": "^16.0.3",
3636
"standard-version": "^9.1.0",
37-
"tap": "^14.11.0"
37+
"tap": "^15.1.6"
3838
},
3939
"files": [
4040
"index.js",
@@ -46,7 +46,6 @@
4646
},
4747
"tap": {
4848
"color": 1,
49-
"coverage": true,
50-
"esm": false
49+
"coverage": true
5150
}
5251
}

package-lock.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
"fastest-levenshtein": "^1.0.12",
107107
"glob": "^7.2.0",
108108
"graceful-fs": "^4.2.8",
109-
"hosted-git-info": "^4.0.2",
109+
"hosted-git-info": "^4.1.0",
110110
"ini": "^2.0.0",
111111
"init-package-json": "^2.0.5",
112112
"is-cidr": "^4.0.2",
@@ -3792,9 +3792,9 @@
37923792
}
37933793
},
37943794
"node_modules/hosted-git-info": {
3795-
"version": "4.0.2",
3796-
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-4.0.2.tgz",
3797-
"integrity": "sha512-c9OGXbZ3guC/xOlCg1Ci/VgWlwsqDv1yMQL1CWqXDL0hDjXuNcq0zuR4xqPSuasI3kqFDhqSyTjREz5gzq0fXg==",
3795+
"version": "4.1.0",
3796+
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-4.1.0.tgz",
3797+
"integrity": "sha512-kyCuEOWjJqZuDbRHzL8V93NzQhwIB71oFWSyzVo+KPZI+pnQPPxucdkrOZvkLRnrf5URsQM+IJ09Dw29cRALIA==",
37983798
"inBundle": true,
37993799
"dependencies": {
38003800
"lru-cache": "^6.0.0"
@@ -10714,6 +10714,7 @@
1071410714
"version": "5.0.0",
1071510715
"license": "ISC",
1071610716
"dependencies": {
10717+
"hosted-git-info": "^4.1.0",
1071710718
"normalize-package-data": "^3.0.2",
1071810719
"npm-package-arg": "^8.1.2",
1071910720
"npm-registry-fetch": "^11.0.0",
@@ -13623,9 +13624,9 @@
1362313624
}
1362413625
},
1362513626
"hosted-git-info": {
13626-
"version": "4.0.2",
13627-
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-4.0.2.tgz",
13628-
"integrity": "sha512-c9OGXbZ3guC/xOlCg1Ci/VgWlwsqDv1yMQL1CWqXDL0hDjXuNcq0zuR4xqPSuasI3kqFDhqSyTjREz5gzq0fXg==",
13627+
"version": "4.1.0",
13628+
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-4.1.0.tgz",
13629+
"integrity": "sha512-kyCuEOWjJqZuDbRHzL8V93NzQhwIB71oFWSyzVo+KPZI+pnQPPxucdkrOZvkLRnrf5URsQM+IJ09Dw29cRALIA==",
1362913630
"requires": {
1363013631
"lru-cache": "^6.0.0"
1363113632
}
@@ -14484,6 +14485,7 @@
1448414485
"libnpmpublish": {
1448514486
"version": "file:workspaces/libnpmpublish",
1448614487
"requires": {
14488+
"hosted-git-info": "^4.1.0",
1448714489
"libnpmpack": "^3.0.0",
1448814490
"lodash.clonedeep": "^4.5.0",
1448914491
"nock": "^12.0.2",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"fastest-levenshtein": "^1.0.12",
7575
"glob": "^7.2.0",
7676
"graceful-fs": "^4.2.8",
77-
"hosted-git-info": "^4.0.2",
77+
"hosted-git-info": "^4.1.0",
7878
"ini": "^2.0.0",
7979
"init-package-json": "^2.0.5",
8080
"is-cidr": "^4.0.2",

workspaces/libnpmpublish/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"bugs": "https://github.com/npm/libnpmpublish/issues",
4242
"homepage": "https://npmjs.com/package/libnpmpublish",
4343
"dependencies": {
44+
"hosted-git-info": "^4.1.0",
4445
"normalize-package-data": "^3.0.2",
4546
"npm-package-arg": "^8.1.2",
4647
"npm-registry-fetch": "^11.0.0",

0 commit comments

Comments
 (0)