MCPcopy
hub / github.com/quantopian/zipline / git_versions_from_keywords

Function git_versions_from_keywords

versioneer.py:955–996  ·  view source on GitHub ↗
(keywords, tag_prefix, verbose)

Source from the content-addressed store, hash-verified

953
954@register_vcs_handler("git", "keywords")
955def git_versions_from_keywords(keywords, tag_prefix, verbose):
956 if not keywords:
957 raise NotThisMethod("no keywords at all, weird")
958 refnames = keywords["refnames"].strip()
959 if refnames.startswith("$Format"):
960 if verbose:
961 print("keywords are unexpanded, not using")
962 raise NotThisMethod("unexpanded keywords, not a git-archive tarball")
963 refs = set([r.strip() for r in refnames.strip("()").split(",")])
964 # starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of
965 # just "foo-1.0". If we see a "tag: " prefix, prefer those.
966 TAG = "tag: "
967 tags = set([r[len(TAG):] for r in refs if r.startswith(TAG)])
968 if not tags:
969 # Either we're using git < 1.8.3, or there really are no tags. We use
970 # a heuristic: assume all version tags have a digit. The old git %d
971 # expansion behaves like git log --decorate=short and strips out the
972 # refs/heads/ and refs/tags/ prefixes that would let us distinguish
973 # between branches and tags. By ignoring refnames without digits, we
974 # filter out many common branch names like "release" and
975 # "stabilization", as well as "HEAD" and "master".
976 tags = set([r for r in refs if re.search(r'\d', r)])
977 if verbose:
978 print("discarding '%s', no digits" % ",".join(refs-tags))
979 if verbose:
980 print("likely tags: %s" % ",".join(sorted(tags)))
981 for ref in sorted(tags):
982 # sorting will prefer e.g. "2.0" over "2.0rc1"
983 if ref.startswith(tag_prefix):
984 r = ref[len(tag_prefix):]
985 if verbose:
986 print("picking %s" % r)
987 return {"version": r,
988 "full-revisionid": keywords["full"].strip(),
989 "dirty": False, "error": None
990 }
991 # no suitable tags, so version is "0+unknown", but full hex is still there
992 if verbose:
993 print("no suitable tags, using unknown + full revision id")
994 return {"version": "0+unknown",
995 "full-revisionid": keywords["full"].strip(),
996 "dirty": False, "error": "no suitable tags"}
997
998
999@register_vcs_handler("git", "pieces_from_vcs")

Callers

nothing calls this directly

Calls 3

joinMethod · 0.80
NotThisMethodClass · 0.70
startswithMethod · 0.45

Tested by

no test coverage detected