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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
Renovate Bot
renovate
Commits
67a7dd4a
Unverified
Commit
67a7dd4a
authored
4 years ago
by
Rhys Arkins
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
refactor: remove unnecessary if from git.setBranch (#6815)
Co-authored-by:
Michael Kriese
<
michael.kriese@visualon.de
>
parent
0a222b82
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/util/git/index.spec.ts
+3
-0
3 additions, 0 deletions
lib/util/git/index.spec.ts
lib/util/git/index.ts
+23
-27
23 additions, 27 deletions
lib/util/git/index.ts
with
26 additions
and
27 deletions
lib/util/git/index.spec.ts
+
3
−
0
View file @
67a7dd4a
...
@@ -114,6 +114,9 @@ describe('platform/git', () => {
...
@@ -114,6 +114,9 @@ describe('platform/git', () => {
});
});
});
});
describe
(
'
isBranchStale()
'
,
()
=>
{
describe
(
'
isBranchStale()
'
,
()
=>
{
beforeEach
(
async
()
=>
{
await
git
.
setBranch
(
'
master
'
);
});
it
(
'
should return false if same SHA as master
'
,
async
()
=>
{
it
(
'
should return false if same SHA as master
'
,
async
()
=>
{
expect
(
await
git
.
isBranchStale
(
'
renovate/future_branch
'
)).
toBe
(
false
);
expect
(
await
git
.
isBranchStale
(
'
renovate/future_branch
'
)).
toBe
(
false
);
});
});
...
...
This diff is collapsed.
Click to expand it.
lib/util/git/index.ts
+
23
−
27
View file @
67a7dd4a
...
@@ -308,22 +308,19 @@ export async function getCommitMessages(): Promise<string[]> {
...
@@ -308,22 +308,19 @@ export async function getCommitMessages(): Promise<string[]> {
}
}
export
async
function
setBranch
(
branchName
:
string
):
Promise
<
string
>
{
export
async
function
setBranch
(
branchName
:
string
):
Promise
<
string
>
{
if
(
branchName
)
{
if
(
!
(
await
branchExists
(
branchName
)))
{
if
(
!
(
await
branchExists
(
branchName
)))
{
throwBranchValidationError
(
branchName
);
throwBranchValidationError
(
branchName
);
}
}
logger
.
debug
(
`Setting current branch to
${
branchName
}
`
);
logger
.
debug
(
`Setting current branch to
${
branchName
}
`
);
config
.
currentBranch
=
branchName
;
try
{
try
{
if
(
branchName
!==
'
master
'
)
{
config
.
currentBranch
=
branchName
;
config
.
currentBranchSha
=
(
config
.
currentBranchSha
=
(
await
git
.
raw
([
'
rev-parse
'
,
'
origin/
'
+
branchName
])
await
git
.
raw
([
'
rev-parse
'
,
'
origin/
'
+
branchName
])
).
trim
();
).
trim
();
}
await
git
.
checkout
([
branchName
,
'
-f
'
]);
await
git
.
checkout
([
branchName
,
'
-f
'
]);
await
git
.
reset
(
ResetMode
.
HARD
);
const
latestCommitDate
=
(
await
git
.
log
({
n
:
1
})).
latest
.
date
;
const
latestCommitDate
=
(
await
git
.
log
({
n
:
1
})).
latest
.
date
;
logger
.
debug
({
branchName
,
latestCommitDate
},
'
latest commit
'
);
logger
.
debug
({
branchName
,
latestCommitDate
},
'
latest commit
'
);
await
git
.
reset
(
ResetMode
.
HARD
);
}
catch
(
err
)
/* istanbul ignore next */
{
}
catch
(
err
)
/* istanbul ignore next */
{
checkForPlatformFailure
(
err
);
checkForPlatformFailure
(
err
);
if
(
if
(
...
@@ -336,7 +333,6 @@ export async function setBranch(branchName: string): Promise<string> {
...
@@ -336,7 +333,6 @@ export async function setBranch(branchName: string): Promise<string> {
}
}
throw
err
;
throw
err
;
}
}
}
return
(
return
(
config
.
currentBranchSha
||
config
.
currentBranchSha
||
(
await
git
.
raw
([
'
rev-parse
'
,
'
origin/master
'
])).
trim
()
(
await
git
.
raw
([
'
rev-parse
'
,
'
origin/master
'
])).
trim
()
...
@@ -396,7 +392,7 @@ export async function isBranchStale(branchName: string): Promise<boolean> {
...
@@ -396,7 +392,7 @@ export async function isBranchStale(branchName: string): Promise<boolean> {
'
--remotes
'
,
'
--remotes
'
,
'
--verbose
'
,
'
--verbose
'
,
'
--contains
'
,
'
--contains
'
,
config
.
currentBranchSha
||
`origin/
${
config
.
currentBranch
}
`
,
config
.
currentBranchSha
,
]);
]);
return
!
branches
.
all
.
map
(
localName
).
includes
(
branchName
);
return
!
branches
.
all
.
map
(
localName
).
includes
(
branchName
);
}
}
...
...
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