@mui/internal-code-infra 0.0.4-canary.56 → 0.0.4-canary.57

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/utils/git.mjs +16 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/internal-code-infra",
3
- "version": "0.0.4-canary.56",
3
+ "version": "0.0.4-canary.57",
4
4
  "author": "MUI Team",
5
5
  "description": "Infra scripts and configs to be used across MUI repos.",
6
6
  "license": "MIT",
@@ -191,7 +191,7 @@
191
191
  "publishConfig": {
192
192
  "access": "public"
193
193
  },
194
- "gitSha": "c0380f22916148bebba5dee261c1a2a3a9211a5e",
194
+ "gitSha": "569d8c88eb773478364ad02e1b25ad1ce2e27782",
195
195
  "scripts": {
196
196
  "build": "tsgo -p tsconfig.build.json",
197
197
  "typescript": "tsgo -noEmit",
package/src/utils/git.mjs CHANGED
@@ -24,6 +24,10 @@ export async function getRepositoryInfo(cwd = process.cwd()) {
24
24
  * @type {Set<string>}
25
25
  */
26
26
  const repoRemotes = new Set();
27
+ /**
28
+ * @type {Map<string, { owner: string, repo: string }>}
29
+ */
30
+ const validRemotes = new Map();
27
31
 
28
32
  for (const line of lines) {
29
33
  // Match pattern: "remoteName url (fetch|push)"
@@ -36,20 +40,25 @@ export async function getRepositoryInfo(cwd = process.cwd()) {
36
40
  cause[remoteName] = `Remote is not a GitHub repository under 'mui' organization: ${url}`;
37
41
  continue;
38
42
  }
39
- return {
40
- owner: parsed.owner,
41
- repo: parsed.name,
42
- remoteName,
43
- };
43
+ if (!validRemotes.has(remoteName)) {
44
+ validRemotes.set(remoteName, { owner: parsed.owner, repo: parsed.name });
45
+ }
44
46
  } catch (error) {
45
47
  cause[remoteName] = `Failed to parse URL for remote ${remoteName}: ${url}`;
46
48
  }
47
- }
48
- if (type !== '(push)') {
49
+ } else if (type !== '(push)') {
49
50
  throw new Error(`Unexpected line format for "git remote -v": "${line}"`);
50
51
  }
51
52
  }
52
53
 
54
+ const preferredOrder = ['upstream', 'origin', ...validRemotes.keys()];
55
+ for (const name of preferredOrder) {
56
+ const match = validRemotes.get(name);
57
+ if (match) {
58
+ return { ...match, remoteName: name };
59
+ }
60
+ }
61
+
53
62
  throw new Error(
54
63
  `Failed to find correct remote(s) in : ${Array.from(repoRemotes.keys()).join(', ')}`,
55
64
  { cause },