@toptal/davinci-cli-shared 2.1.1-alpha-temp-debug-logs-ddc5a51f.2 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Change Log
2
2
 
3
+ ## 2.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1880](https://github.com/toptal/davinci/pull/1880) [`de1d21ca`](https://github.com/toptal/davinci/commit/de1d21cac8b6a4ee63bdbb38924d26b75735f88a) Thanks [@augustobmoura](https://github.com/augustobmoura)! - ---
8
+
9
+ - add missing support for git repos with remotes that don't end on the .git extension
10
+
3
11
  ## 2.1.0
4
12
 
5
13
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toptal/davinci-cli-shared",
3
- "version": "2.1.1-alpha-temp-debug-logs-ddc5a51f.2+ddc5a51f",
3
+ "version": "2.1.1",
4
4
  "description": "Shared CLI code and CLI engine for davinci",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -36,6 +36,5 @@
36
36
  },
37
37
  "devDependencies": {
38
38
  "@jest/globals": "28.1.0"
39
- },
40
- "gitHead": "ddc5a51f7f07bdd37f8a69075e8df1508e9da704"
39
+ }
41
40
  }
@@ -8,8 +8,6 @@ import { gatherUsageData } from './usage-data.js'
8
8
  const sendMetrics = async (startTime, metadata) => {
9
9
  const executionTimeNs = Number(process.hrtime.bigint() - startTime)
10
10
 
11
- console.log('[DEBUG] pwd: %s', process.cwd())
12
-
13
11
  const { commandIdentifier, davinciCommand } = metadata
14
12
 
15
13
  try {
@@ -10,29 +10,33 @@ import { isCi } from '../ci.js'
10
10
  const TOPTAL_SSH_REPO_URL_REGEX =
11
11
  /^git@github\.com:\/?toptal\/([A-Za-z0-9_.-]+)\.git$/
12
12
 
13
- const TOPTAL_HTTPS_REPO_URL_REGEX =
14
- /^https:\/\/github\.com\/toptal\/([A-Za-z0-9_.-]+)\.git$/
15
-
16
13
  const UNKNOWN = '<unknown>'
17
14
 
18
15
  const getProjectName = async () => {
19
16
  const gitProcess = await execa('git', ['remote', 'get-url', 'origin'])
20
- const repoOriginUrl = gitProcess.stdout
21
-
22
- console.log('[DEBUG] origin: %s', repoOriginUrl)
17
+ const repoOriginUrl = gitProcess.stdout ?? ''
23
18
 
24
- // Not matching with a pattern means that either:
19
+ // We try matching the url with the ssh protocol, or parsing it as an URL
20
+ // Failing both of the checks means:
25
21
  // 1. Project is not from toptal, so not relevant information
26
22
  // 2. Project is not on github, unlikely for toptal
27
23
  // 3. User is using an ssh alias, in this case we cannot catch it in a sane way otherwise
28
- const toptalRepoFound = [
29
- TOPTAL_SSH_REPO_URL_REGEX,
30
- TOPTAL_HTTPS_REPO_URL_REGEX,
31
- ]
32
- .map(pattern => repoOriginUrl?.match(pattern))
33
- .find(Boolean)
34
-
35
- return toptalRepoFound?.[1] ?? UNKNOWN
24
+ const sshMatch = repoOriginUrl.match(TOPTAL_SSH_REPO_URL_REGEX)
25
+
26
+ if (sshMatch) {
27
+ return sshMatch[1]
28
+ }
29
+
30
+ if (repoOriginUrl.startsWith('https://')) {
31
+ const url = new URL(repoOriginUrl)
32
+ const { dir, name } = path.parse(url.pathname)
33
+
34
+ if (url.hostname === 'github.com' && dir === '/toptal') {
35
+ return name
36
+ }
37
+ }
38
+
39
+ return UNKNOWN
36
40
  }
37
41
 
38
42
  const getGitBranch = async () => {