Hi,
in #1511112: git_deploy slows down module install/enable massively we are trying to make this module faster.
Besides adding caches, one way to make it faster would be to optimize the git commands.
However, I currently am a bit confused by the purpose of the commands.
Could you shed some light?
exec("$git rev-parse --abbrev-ref HEAD 2>&1", $branch);
$tag_found = FALSE;
if ($branch) {
$branch = $branch[0];
This produces $branch === 'HEAD'
in case we are not on a branch. So the if ($branch)
is always true.
// Now try to find a tag.
exec("$git rev-list --topo-order --max-count=1 HEAD 2>&1", $last_tag_hash);
Doesn't this simply give us the hash of HEAD? It does not really care which tag.
exec("$git describe --tags $last_tag_hash[0] 2>&1", $last_tag);
So why not simply "$git describe --tags HEAD
?
Also, why not use the --match <pattern>
parameter of git describe
?
And what if the first tag found by describe is something custom, which prevents a correct version resolution?
Maybe something like this?
git log --topo-order --simplify-by-decoration --format=format:%d HEAD
The output is like this:
(tag: 7.x-2.x-1511112-53-combined)
(tag: 7.x-2.x-1511112-50-static-cache-per-git-dir)
(HEAD, tag: xxxx, origin/HEAD, origin/7.x-2.x, 7.x-2.x)
(tag: 7.x-2.2)
(tag: 7.x-2.1)
(tag: 7.x-2.0)
The goal would be to use as few exec() as possible, but also not let one exec() become too expensive.
I post this as a support request. The goal of this issue is to understand the design choices for the existing code. We will see where it goes from there.
Comments
Comment #2
donquixote CreditAttribution: donquixote as a volunteer commentedI was about to create a new issue "$last_tag_has is always HEAD -> can be simplified.".
Now I notice I already noticed and reported all of this in the past.
I am changing this from "Support request" to "Task", because I am now quite confident that this is a flaw in the module.
Comment #3
Darren OhLogic and performance of version detection are fixed in #1254200-6: Fix dev release time. Please review and test.
Comment #4
Darren Oh