aboutsummaryrefslogtreecommitdiff
path: root/sandbox/testAppNevena/Front/node_modules/hosted-git-info/git-host.js
diff options
context:
space:
mode:
authorDanijel Andjelkovic <adanijel99@gmail.com>2022-03-01 20:21:29 +0000
committerDanijel Andjelkovic <adanijel99@gmail.com>2022-03-01 20:21:29 +0000
commit61cb1570a3410c85a4489b97c172e3a50715f36c (patch)
tree8fe4a5b77ea54bba80abc817ce2c9ef0e79e7e66 /sandbox/testAppNevena/Front/node_modules/hosted-git-info/git-host.js
parent21a53d349788c99d2007cba91a923db982353b31 (diff)
parenta9ee9e0a500a4a15bd0b5dcaf041f827228ed309 (diff)
Merge branch 'researchML' into 'dev'
Research ml See merge request igrannonica/neuronstellar!6
Diffstat (limited to 'sandbox/testAppNevena/Front/node_modules/hosted-git-info/git-host.js')
-rw-r--r--sandbox/testAppNevena/Front/node_modules/hosted-git-info/git-host.js110
1 files changed, 110 insertions, 0 deletions
diff --git a/sandbox/testAppNevena/Front/node_modules/hosted-git-info/git-host.js b/sandbox/testAppNevena/Front/node_modules/hosted-git-info/git-host.js
new file mode 100644
index 00000000..8a975e92
--- /dev/null
+++ b/sandbox/testAppNevena/Front/node_modules/hosted-git-info/git-host.js
@@ -0,0 +1,110 @@
+'use strict'
+const gitHosts = require('./git-host-info.js')
+
+class GitHost {
+ constructor (type, user, auth, project, committish, defaultRepresentation, opts = {}) {
+ Object.assign(this, gitHosts[type])
+ this.type = type
+ this.user = user
+ this.auth = auth
+ this.project = project
+ this.committish = committish
+ this.default = defaultRepresentation
+ this.opts = opts
+ }
+
+ hash () {
+ return this.committish ? `#${this.committish}` : ''
+ }
+
+ ssh (opts) {
+ return this._fill(this.sshtemplate, opts)
+ }
+
+ _fill (template, opts) {
+ if (typeof template === 'function') {
+ const options = { ...this, ...this.opts, ...opts }
+
+ // the path should always be set so we don't end up with 'undefined' in urls
+ if (!options.path) {
+ options.path = ''
+ }
+
+ // template functions will insert the leading slash themselves
+ if (options.path.startsWith('/')) {
+ options.path = options.path.slice(1)
+ }
+
+ if (options.noCommittish) {
+ options.committish = null
+ }
+
+ const result = template(options)
+ return options.noGitPlus && result.startsWith('git+') ? result.slice(4) : result
+ }
+
+ return null
+ }
+
+ sshurl (opts) {
+ return this._fill(this.sshurltemplate, opts)
+ }
+
+ browse (path, fragment, opts) {
+ // not a string, treat path as opts
+ if (typeof path !== 'string') {
+ return this._fill(this.browsetemplate, path)
+ }
+
+ if (typeof fragment !== 'string') {
+ opts = fragment
+ fragment = null
+ }
+ return this._fill(this.browsefiletemplate, { ...opts, fragment, path })
+ }
+
+ docs (opts) {
+ return this._fill(this.docstemplate, opts)
+ }
+
+ bugs (opts) {
+ return this._fill(this.bugstemplate, opts)
+ }
+
+ https (opts) {
+ return this._fill(this.httpstemplate, opts)
+ }
+
+ git (opts) {
+ return this._fill(this.gittemplate, opts)
+ }
+
+ shortcut (opts) {
+ return this._fill(this.shortcuttemplate, opts)
+ }
+
+ path (opts) {
+ return this._fill(this.pathtemplate, opts)
+ }
+
+ tarball (opts) {
+ return this._fill(this.tarballtemplate, { ...opts, noCommittish: false })
+ }
+
+ file (path, opts) {
+ return this._fill(this.filetemplate, { ...opts, path })
+ }
+
+ getDefaultRepresentation () {
+ return this.default
+ }
+
+ toString (opts) {
+ if (this.default && typeof this[this.default] === 'function') {
+ return this[this.default](opts)
+ }
+
+ return this.sshurl(opts)
+ }
+}
+module.exports = GitHost