Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def branch_head(username: str, ghnum: GhNumber) -> GitCommitHash:
return branch(username, ghnum, "head")
def branch_orig(username: str, ghnum: GhNumber) -> GitCommitHash:
return branch(username, ghnum, "orig")
STACK_HEADER = "Stack from [ghstack](https://github.com/ezyang/ghstack)"
@dataclass
class DiffWithGitHubMetadata:
diff: ghstack.diff.Diff
number: GitHubNumber
# Really ought not to be optional, but for BC reasons it might be
remote_source_id: Optional[str]
title: str
body: str
closed: bool
ghnum: GhNumber
pull_request_resolved: ghstack.diff.PullRequestResolved
def main(msg: Optional[str],
username: str,
github: ghstack.github.GitHubEndpoint,
update_fields: bool = False,
sh: Optional[ghstack.shell.Shell] = None,
stack_header: str = STACK_HEADER,
# The orig commit of the prev diff we submitted. This
# corresponds to the 'orig' branch in GH.
base_orig: GitCommitHash
# Message describing the update to the stack that was done
msg: Optional[str]
# Description of all the diffs we submitted; to be populated
# by Submitter.
stack_meta: List[DiffMeta]
# List of input diffs which we ignored (i.e., treated as if they
# did not exist on the stack at all), because they were associated
# with a patch that contains no changes. GhNumber may be false
# if the diff was never associated with a PR.
ignored_diffs: List[Tuple[ghstack.diff.Diff, Optional[GitHubNumber]]]
# List of diffs to process, in chronological order
stack: List[ghstack.diff.Diff]
# Set of seen ghnums
seen_ghnums: Set[GhNumber]
# String used to describe the stack in question
stack_header: str
# Clobber existing PR description with local commit message
update_fields: bool
# Print only PR URL to stdout
short: bool
def convert(h: CommitHeader) -> ghstack.diff.Diff:
parents = h.parents()
if len(parents) != 1:
raise RuntimeError(
"The commit {} has {} parents, which makes my head explode. "
"`git rebase -i` your diffs into a stack, then try again."
.format(h.commit_id(), len(parents)))
return ghstack.diff.Diff(
title=h.title(),
summary=h.commit_msg(),
oid=h.commit_id(),
source_id=h.tree(),
pull_request_resolved=ghstack.diff.PullRequestResolved.search(h.raw_header),
patch=GitPatch(h)
)