Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
renovate
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
Renovate Bot
renovate
Commits
939f3d6a
Unverified
Commit
939f3d6a
authored
4 years ago
by
Michael Kriese
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
feat(git-submodules): fetch default branch (#7391)
parent
78a3f604
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/manager/git-submodules/extract.spec.ts
+8
-0
8 additions, 0 deletions
lib/manager/git-submodules/extract.spec.ts
lib/manager/git-submodules/extract.ts
+15
-3
15 additions, 3 deletions
lib/manager/git-submodules/extract.ts
with
23 additions
and
3 deletions
lib/manager/git-submodules/extract.spec.ts
+
8
−
0
View file @
939f3d6a
...
@@ -27,6 +27,13 @@ describe('lib/manager/gitsubmodules/extract', () => {
...
@@ -27,6 +27,13 @@ describe('lib/manager/gitsubmodules/extract', () => {
}
}
return
git
.
raw
(
options
);
return
git
.
raw
(
options
);
},
},
listRemote
():
Response
<
string
>
{
return
partial
<
Response
<
string
>>
(
Promise
.
resolve
(
'
ref: refs/heads/main HEAD
\n
5701164b9f5edba1f6ca114c491a564ffb55a964 HEAD
'
)
);
},
};
};
});
});
});
});
...
@@ -38,6 +45,7 @@ describe('lib/manager/gitsubmodules/extract', () => {
...
@@ -38,6 +45,7 @@ describe('lib/manager/gitsubmodules/extract', () => {
).
toBeNull
();
).
toBeNull
();
res
=
await
extractPackageFile
(
''
,
'
.gitmodules.2
'
,
{
localDir
});
res
=
await
extractPackageFile
(
''
,
'
.gitmodules.2
'
,
{
localDir
});
expect
(
res
.
deps
).
toHaveLength
(
1
);
expect
(
res
.
deps
).
toHaveLength
(
1
);
expect
(
res
.
deps
[
0
].
registryUrls
[
1
]).
toEqual
(
'
main
'
);
res
=
await
extractPackageFile
(
''
,
'
.gitmodules.3
'
,
{
localDir
});
res
=
await
extractPackageFile
(
''
,
'
.gitmodules.3
'
,
{
localDir
});
expect
(
res
.
deps
).
toHaveLength
(
1
);
expect
(
res
.
deps
).
toHaveLength
(
1
);
res
=
await
extractPackageFile
(
''
,
'
.gitmodules.4
'
,
{
localDir
});
res
=
await
extractPackageFile
(
''
,
'
.gitmodules.4
'
,
{
localDir
});
...
...
This diff is collapsed.
Click to expand it.
lib/manager/git-submodules/extract.ts
+
15
−
3
View file @
939f3d6a
...
@@ -34,9 +34,17 @@ async function getUrl(
...
@@ -34,9 +34,17 @@ async function getUrl(
return
URL
.
resolve
(
`
${
remoteUrl
}
/`
,
path
);
return
URL
.
resolve
(
`
${
remoteUrl
}
/`
,
path
);
}
}
const
headRefRe
=
/ref: refs
\/
heads
\/(?<
branch>
\w
+
)\s
/
;
async
function
getDefaultBranch
(
subModuleUrl
:
string
):
Promise
<
string
>
{
const
val
=
await
Git
().
listRemote
([
'
--symref
'
,
subModuleUrl
,
'
HEAD
'
]);
return
headRefRe
.
exec
(
val
)?.
groups
?.
branch
??
'
master
'
;
}
async
function
getBranch
(
async
function
getBranch
(
gitModulesPath
:
string
,
gitModulesPath
:
string
,
submoduleName
:
string
submoduleName
:
string
,
subModuleUrl
:
string
):
Promise
<
string
>
{
):
Promise
<
string
>
{
return
(
return
(
(
await
Git
().
raw
([
(
await
Git
().
raw
([
...
@@ -45,7 +53,7 @@ async function getBranch(
...
@@ -45,7 +53,7 @@ async function getBranch(
gitModulesPath
,
gitModulesPath
,
'
--get
'
,
'
--get
'
,
`submodule.
${
submoduleName
}
.branch`
,
`submodule.
${
submoduleName
}
.branch`
,
]))
||
'
master
'
]))
||
(
await
getDefaultBranch
(
subModuleUrl
))
).
trim
();
).
trim
();
}
}
...
@@ -99,8 +107,12 @@ export default async function extractPackageFile(
...
@@ -99,8 +107,12 @@ export default async function extractPackageFile(
const
[
currentValue
]
=
(
await
git
.
subModule
([
'
status
'
,
path
]))
const
[
currentValue
]
=
(
await
git
.
subModule
([
'
status
'
,
path
]))
.
trim
()
.
trim
()
.
split
(
/
[
+
\s]
/
);
.
split
(
/
[
+
\s]
/
);
const
submoduleBranch
=
await
getBranch
(
gitModulesPath
,
name
);
const
subModuleUrl
=
await
getUrl
(
git
,
gitModulesPath
,
name
);
const
subModuleUrl
=
await
getUrl
(
git
,
gitModulesPath
,
name
);
const
submoduleBranch
=
await
getBranch
(
gitModulesPath
,
name
,
subModuleUrl
);
return
{
return
{
depName
:
path
,
depName
:
path
,
registryUrls
:
[
subModuleUrl
,
submoduleBranch
],
registryUrls
:
[
subModuleUrl
,
submoduleBranch
],
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment