mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-29 17:47:14 +02:00
Avoid working with detached / non-existent git branches when checking for updates (#4217)
* Avoid working with detached / non-existent git branches when checking for updates b/c we can't use `pull` anyway in that situation Otherwise, ask for the specific branch via `refs/heads/{branch}` and also fail when it is not available * Update vcsclient.py Co-authored-by: Ivan Kravets <me@ikravets.com>
This commit is contained in:
@ -72,9 +72,14 @@ class PackageManagerUpdateMixin(object):
|
||||
return None
|
||||
if not vcs.can_be_updated:
|
||||
return None
|
||||
|
||||
vcs_revision = vcs.get_latest_revision()
|
||||
if not vcs_revision:
|
||||
return None
|
||||
|
||||
return str(
|
||||
self.build_metadata(
|
||||
pkg.path, pkg.metadata.spec, vcs_revision=vcs.get_latest_revision()
|
||||
pkg.path, pkg.metadata.spec, vcs_revision=vcs_revision
|
||||
).version
|
||||
)
|
||||
|
||||
|
@ -217,12 +217,18 @@ class GitClient(VCSClientBase):
|
||||
return self.get_current_revision()
|
||||
branch = self.get_current_branch()
|
||||
if not branch:
|
||||
return self.get_current_revision()
|
||||
result = self.get_cmd_output(["ls-remote"])
|
||||
return None
|
||||
|
||||
branch_ref = f"refs/heads/{branch}"
|
||||
result = self.get_cmd_output(["ls-remote", self.remote_url, branch_ref])
|
||||
if not result:
|
||||
return None
|
||||
|
||||
for line in result.split("\n"):
|
||||
ref_pos = line.strip().find("refs/heads/" + branch)
|
||||
if ref_pos > 0:
|
||||
return line[:ref_pos].strip()[:7]
|
||||
sha, ref = line.strip().split("\t")
|
||||
if ref == branch_ref:
|
||||
return sha[:7]
|
||||
|
||||
return None
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user