- def fetch(self, v: Verification, section: str,
- conf: configparser.SectionProxy) -> str:
- if 'git_revision' not in conf or 'release_name' not in conf:
- raise Exception(
- 'Cannot update unpinned channel "%s" (Run "pin" before "update")' %
- section)
- the_pin = GitPin(
- release_name=conf['release_name'],
- git_revision=conf['git_revision'])
-
- ensure_git_rev_available(v, self, the_pin, None)
- return git_get_tarball(v, self, the_pin)
-
-
-class ChannelSearchPath(TarrableSearchPath):
- def pin(self, v: Verification) -> ChannelPin:
- old_revision = (
- self.git_revision if hasattr(self, 'git_revision') else None)
- if hasattr(self, 'git_revision'):
- del self.git_revision
-
- fetch(v, self)
- new_gitpin = parse_channel(v, self)
- fetch_resources(v, self, new_gitpin)
- ensure_git_rev_available(v, self, new_gitpin, old_revision)
- check_channel_contents(v, self, new_gitpin)
+ def fetch(self, v: Verification, pin: Pin) -> str:
+ assert isinstance(pin, GitPin)
+ git_cache.ensure_rev_available(
+ self.git_repo, self.git_ref, pin.git_revision)
+ return git_get_tarball(v, self, pin)
+
+
+class ChannelSearchPath(NamedTuple):
+ channel_url: str
+ git_ref: str
+ git_repo: str
+
+ def pin(self, v: Verification, old_pin: Optional[Pin]) -> ChannelPin:
+ if old_pin is not None:
+ assert isinstance(old_pin, ChannelPin)
+
+ channel_html, forwarded_url = fetch_channel(v, self)
+ table, new_gitpin = parse_channel(v, channel_html)
+ if old_pin is not None and old_pin.git_revision == new_gitpin.git_revision:
+ return old_pin
+ fetch_resources(v, new_gitpin, forwarded_url, table)
+ git_cache.ensure_rev_available(
+ self.git_repo, self.git_ref, new_gitpin.git_revision)
+ if old_pin is not None:
+ verify_git_ancestry(
+ v, self, old_pin.git_revision, new_gitpin.git_revision)
+ check_channel_contents(v, self, table, new_gitpin)