mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-10 11:45:45 +03:00
gclient2nix: distinguish between revs and tags
This commit is contained in:
parent
527595ee43
commit
cb8484366b
1 changed files with 7 additions and 5 deletions
|
@ -125,7 +125,7 @@ class GitRepo(Repo):
|
||||||
self.fetcher = "fetchgit"
|
self.fetcher = "fetchgit"
|
||||||
self.args = {
|
self.args = {
|
||||||
"url": url,
|
"url": url,
|
||||||
"rev": rev,
|
"rev" if re.match(r"[0-9a-f]{40}", rev) else "tag": rev,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -136,13 +136,14 @@ class GitHubRepo(Repo):
|
||||||
self.args = {
|
self.args = {
|
||||||
"owner": owner,
|
"owner": owner,
|
||||||
"repo": repo,
|
"repo": repo,
|
||||||
"rev": rev,
|
"rev" if re.match(r"[0-9a-f]{40}", rev) else "tag": rev,
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_file(self, filepath: str) -> str:
|
def get_file(self, filepath: str) -> str:
|
||||||
|
rev_or_tag = self.args['rev'] if 'rev' in self.args else f"refs/tags/{self.args['tag']}"
|
||||||
return (
|
return (
|
||||||
urlopen(
|
urlopen(
|
||||||
f"https://raw.githubusercontent.com/{self.args['owner']}/{self.args['repo']}/{self.args['rev']}/{filepath}"
|
f"https://raw.githubusercontent.com/{self.args['owner']}/{self.args['repo']}/{rev_or_tag}/{filepath}"
|
||||||
)
|
)
|
||||||
.read()
|
.read()
|
||||||
.decode("utf-8")
|
.decode("utf-8")
|
||||||
|
@ -155,7 +156,7 @@ class GitilesRepo(Repo):
|
||||||
self.fetcher = "fetchFromGitiles"
|
self.fetcher = "fetchFromGitiles"
|
||||||
self.args = {
|
self.args = {
|
||||||
"url": url,
|
"url": url,
|
||||||
"rev": rev,
|
"rev" if re.match(r"[0-9a-f]{40}", rev) else "tag": rev,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Quirk: Chromium source code exceeds the Hydra output limit
|
# Quirk: Chromium source code exceeds the Hydra output limit
|
||||||
|
@ -172,9 +173,10 @@ class GitilesRepo(Repo):
|
||||||
self.args["postFetch"] += "rm -r $out/media/test/data; "
|
self.args["postFetch"] += "rm -r $out/media/test/data; "
|
||||||
|
|
||||||
def get_file(self, filepath: str) -> str:
|
def get_file(self, filepath: str) -> str:
|
||||||
|
rev_or_tag = self.args['rev'] if 'rev' in self.args else f"refs/tags/{self.args['tag']}"
|
||||||
return base64.b64decode(
|
return base64.b64decode(
|
||||||
urlopen(
|
urlopen(
|
||||||
f"{self.args['url']}/+/{self.args['rev']}/{filepath}?format=TEXT"
|
f"{self.args['url']}/+/{rev_or_tag}/{filepath}?format=TEXT"
|
||||||
).read()
|
).read()
|
||||||
).decode("utf-8")
|
).decode("utf-8")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue