Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Mkfree Deploy
Commits
edb0305b
Commit
edb0305b
authored
4 years ago
by
oyhk
Browse files
Options
Download
Email Patches
Plain Diff
[opt] 优化项目分支排序,按照分支创建时间倒序
parent
b1eb6e06
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
backend/src/project/project.controller.ts
+5
-7
backend/src/project/project.controller.ts
with
5 additions
and
7 deletions
+5
-7
backend/src/project/project.controller.ts
+
5
-
7
View file @
edb0305b
...
...
@@ -75,7 +75,7 @@ export class ProjectController {
const
r
=
new
ApiResult
();
const
p
=
new
Page
();
console
.
log
(
'
dto
'
,
dto
);
console
.
log
(
'
dto
'
,
dto
);
const
projectDtoList
:
ProjectDto
[]
=
[];
const
envList
=
await
this
.
envRepository
.
find
({
isEnable
:
true
});
...
...
@@ -698,17 +698,15 @@ export class ProjectController {
const
shell
=
`
cd
${
installPathSystemConfig
.
value
}${
SystemConfigValues
.
jobPath
}
/
${
project
.
name
}
/default
git pull
git branch -a
for branch in
\`
git branch -r | grep -v HEAD
\`
;do echo -e
\`
git show --format="%ci %cr" $branch | head -n 1
\`
$branch; done | sort -r
`
;
exec
(
shell
,
{},
async
(
exception
,
stdout
,
stderr
)
=>
{
// console.log('stdout',stdout);
let
branchList
=
stdout
.
split
(
'
\n
'
);
branchList
=
branchList
.
filter
(
branch
=>
{
return
branch
.
indexOf
(
'
Already up to date.
'
)
===
-
1
&&
branch
.
indexOf
(
'
remotes/origin
'
)
!==
-
1
&&
branch
.
indexOf
(
'
remotes/origin/HEAD
'
)
===
-
1
;
}).
map
(
branch
=>
branch
.
trim
()).
map
(
branch
=>
branch
.
replace
(
'
remotes/origin/
'
,
''
)).
reverse
();
branchList
=
branchList
.
filter
(
branch
=>
(
branch
.
includes
(
'
origin
'
)
&&
branch
.
indexOf
(
'
more items
'
)
===
-
1
))
.
map
(
branch
=>
branch
.
trim
())
.
map
(
branch
=>
branch
.
substr
(
branch
.
indexOf
(
'
origin
'
)
+
7
));
// 截取 origin/ 后的分支名称
console
.
log
(
'
branchList
'
,
branchList
);
await
this
.
projectRepository
.
update
(
project
.
id
,
{
branchList
:
JSON
.
stringify
(
branchList
)
});
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help