Currently, when listing branches, we provide the branch name and the last commit for each branch. The current implementation of this part is very slow. It consists 2 steps:
- List all the branches
- For each branch in the list, get the last commit by doing:
- Ensure the branch existence (List all the branches, and for-loop to find out if it contains the target branch)
- If branch exists, then get the last commit metadata
Because the branch existence (step 2.1) is a for-loop for all the branches, it's an expensive operation which is very time-consuming.
Merge method getLastChange into branch listing. The new implementation will keep using Git command git-branch, and will go even further—it should resolve the pointer stored in each branch file under Git folder .git/refs/remotes/. The pointer is a SHA1 commit hash, which points to the last commit of the branch.
The result will be wrapped into Studio Business model BranchInfo directly.
However, we will still keep method getLastChange for other usages (only for tests).
- Add unit test to measure the performance of the new branch listing.
- Reuse the code of ticket
NXS-4269to performance manually (results have been added into that ticket).