BitBucket: Use commit hash instead of branch name when the branch is not URL-safe.
Apparently, the "/src" subsection of the BitBucket API doesn't do well with branch names that contain slashes. urlencode() doesn't help. See #409 for the initial report.
This commit is contained in:
parent
0edd15f678
commit
369c19ab1a
|
|
@ -59,8 +59,16 @@ if ( !class_exists('Puc_v4p10_Vcs_BitBucketApi', false) ):
|
|||
return null;
|
||||
}
|
||||
|
||||
//The "/src/{stuff}/{path}" endpoint doesn't seem to handle branch names that contain slashes.
|
||||
//If we don't encode the slash, we get a 404. If we encode it as "%2F", we get a 401.
|
||||
//To avoid issues, if the branch name is not URL-safe, let's use the commit hash instead.
|
||||
$ref = $branch->name;
|
||||
if ((urlencode($ref) !== $ref) && isset($branch->target->hash)) {
|
||||
$ref = $branch->target->hash;
|
||||
}
|
||||
|
||||
return new Puc_v4p10_Vcs_Reference(array(
|
||||
'name' => $branch->name,
|
||||
'name' => $ref,
|
||||
'updated' => $branch->target->date,
|
||||
'downloadUrl' => $this->getDownloadUrl($branch->name),
|
||||
));
|
||||
|
|
|
|||
Loading…
Reference in New Issue