Commit edb0305b authored by oyhk's avatar oyhk
Browse files

[opt] 优化项目分支排序,按照分支创建时间倒序

parent b1eb6e06
Showing with 5 additions and 7 deletions
+5 -7
......@@ -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) });
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment