use of com.google.copybara.git.GitHubPrOrigin.ReviewState in project copybara by google.
the class GitModule method githubPrOrigin.
@SuppressWarnings("unused")
@StarlarkMethod(name = GITHUB_PR_ORIGIN_NAME, doc = "Defines a Git origin for Github pull requests.\n" + "\n" + "Implicit labels that can be used/exposed:\n" + "\n" + " - " + GitHubPrOrigin.GITHUB_PR_NUMBER_LABEL + ": The pull request number if the" + " reference passed was in the form of `https://github.com/project/pull/123`, " + " `refs/pull/123/head` or `refs/pull/123/master`.\n" + " - " + DEFAULT_INTEGRATE_LABEL + ": A label that when exposed, can be used to" + " integrate automatically in the reverse workflow.\n" + " - " + GITHUB_BASE_BRANCH + ": The name of the branch which serves as the base for the Pull Request.\n" + " - " + GITHUB_BASE_BRANCH_SHA1 + ": The SHA-1 of the commit used as baseline. Generally, the baseline commit is the" + " point of divergence between the PR's 'base' and 'head' branches. When `use_merge" + " = True` is specified, the baseline is instead the tip of the PR's base branch.\n" + " - " + GITHUB_PR_USE_MERGE + ": Equal to 'true' if the workflow is importing a GitHub PR 'merge' commit and" + " 'false' when importing a GitHub PR 'head' commit.\n" + " - " + GITHUB_PR_TITLE + ": Title of the Pull Request.\n" + " - " + GITHUB_PR_BODY + ": Body of the Pull Request.\n" + " - " + GITHUB_PR_URL + ": GitHub url of the Pull Request.\n" + " - " + GITHUB_PR_HEAD_SHA + ": The SHA-1 of the head commit of the pull request.\n" + " - " + GITHUB_PR_USER + ": The login of the author the pull request.\n" + " - " + GITHUB_PR_ASSIGNEE + ": A repeated label with the login of the assigned" + " users.\n" + " - " + GITHUB_PR_REVIEWER_APPROVER + ": A repeated label with the login of users" + " that have participated in the review and that can approve the import. Only" + " populated if `review_state` field is set. Every reviewers type matching" + " `review_approvers` will be added to this list.\n" + " - " + GITHUB_PR_REVIEWER_OTHER + ": A repeated label with the login of users" + " that have participated in the review but cannot approve the import. Only" + " populated if `review_state` field is set.\n", parameters = { @Param(name = "url", named = true, doc = "Indicates the URL of the GitHub repository"), @Param(name = "use_merge", defaultValue = "False", named = true, positional = false, doc = "If the content for refs/pull/<ID>/merge should be used instead of the PR" + " head. The GitOrigin-RevId still will be the one from" + " refs/pull/<ID>/head revision."), @Param(name = GitHubUtil.REQUIRED_LABELS, allowedTypes = { @ParamType(type = Sequence.class, generic1 = String.class) }, named = true, defaultValue = "[]", doc = "Required labels to import the PR. All the labels need to be present in order to" + " migrate the Pull Request.", positional = false), @Param(name = GitHubUtil.REQUIRED_STATUS_CONTEXT_NAMES, allowedTypes = { @ParamType(type = Sequence.class, generic1 = String.class) }, named = true, defaultValue = "[]", doc = "A list of names of services which must all mark the PR with 'success' before it" + " can be imported.<br><br>See" + " https://docs.github.com/en/rest/reference/repos#statuses", positional = false), @Param(name = GitHubUtil.REQUIRED_CHECK_RUNS, allowedTypes = { @ParamType(type = Sequence.class, generic1 = String.class) }, named = true, defaultValue = "[]", doc = "A list of check runs which must all have a value of 'success' in order to import" + " the PR.<br><br>See" + " https://docs.github.com/en/rest/guides/getting-started-with-the-checks-api", positional = false), @Param(name = GitHubUtil.RETRYABLE_LABELS, allowedTypes = { @ParamType(type = Sequence.class, generic1 = String.class) }, named = true, defaultValue = "[]", doc = "Required labels to import the PR that should be retried. This parameter must" + " be a subset of required_labels.", positional = false), @Param(name = "submodules", defaultValue = "'NO'", named = true, positional = false, doc = "Download submodules. Valid values: NO, YES, RECURSIVE."), @Param(name = "baseline_from_branch", named = true, doc = "WARNING: Use this field only for github -> git CHANGE_REQUEST workflows.<br>" + "When the field is set to true for CHANGE_REQUEST workflows it will find the" + " baseline comparing the Pull Request with the base branch instead of looking" + " for the *-RevId label in the commit message.", defaultValue = "False", positional = false), @Param(name = "first_parent", defaultValue = "True", named = true, doc = "If true, it only uses the first parent when looking for changes. Note that" + " when disabled in ITERATIVE mode, it will try to do a migration for each" + " change of the merged branch.", positional = false), @Param(name = "partial_fetch", defaultValue = "False", named = true, positional = false, doc = "This is an experimental feature that only works for certain origin globs."), @Param(name = "state", defaultValue = "'OPEN'", named = true, positional = false, doc = "Only migrate Pull Request with that state." + " Possible values: `'OPEN'`, `'CLOSED'` or `'ALL'`. Default 'OPEN'"), @Param(name = "review_state", allowedTypes = { @ParamType(type = String.class), @ParamType(type = NoneType.class) }, defaultValue = "None", named = true, positional = false, doc = "Required state of the reviews associated with the Pull Request" + " Possible values: `'HEAD_COMMIT_APPROVED'`, `'ANY_COMMIT_APPROVED'`," + " `'HAS_REVIEWERS'` or `'ANY'`. Default `None`. This field is required if" + " the user wants `" + GITHUB_PR_REVIEWER_APPROVER + "` and `" + GITHUB_PR_REVIEWER_OTHER + "` labels populated"), @Param(name = "review_approvers", allowedTypes = { @ParamType(type = Sequence.class, generic1 = String.class), @ParamType(type = NoneType.class) }, defaultValue = "None", named = true, positional = false, doc = "The set of reviewer types that are considered for approvals. In order to" + " have any effect, `review_state` needs to be set. " + GITHUB_PR_REVIEWER_APPROVER + "` will be populated for these types." + " See the valid types here:" + " https://developer.github.com/v4/enum/commentauthorassociation/"), @Param(name = "api_checker", allowedTypes = { @ParamType(type = Checker.class), @ParamType(type = NoneType.class) }, defaultValue = "None", doc = "A checker for the GitHub API endpoint provided for after_migration hooks. " + "This field is not required if the workflow hooks don't use the " + "origin/destination endpoints.", named = true, positional = false), @Param(name = PATCH_FIELD, allowedTypes = { @ParamType(type = Transformation.class), @ParamType(type = NoneType.class) }, defaultValue = "None", named = true, positional = false, doc = PATCH_FIELD_DESC), @Param(name = "branch", allowedTypes = { @ParamType(type = String.class), @ParamType(type = NoneType.class) }, named = true, positional = false, defaultValue = "None", doc = "If set, it will only migrate pull requests for this base branch"), @Param(name = "describe_version", allowedTypes = { @ParamType(type = Boolean.class), @ParamType(type = NoneType.class) }, defaultValue = "None", named = true, positional = false, doc = DESCRIBE_VERSION_FIELD_DOC) }, useStarlarkThread = true)
@UsesFlags(GitHubPrOriginOptions.class)
@DocDefault(field = "review_approvers", value = "[\"COLLABORATOR\", \"MEMBER\", \"OWNER\"]")
public GitHubPrOrigin githubPrOrigin(String url, Boolean merge, // <String>
Sequence<?> requiredLabels, // <String>
Sequence<?> requiredStatusContextNames, // <String>
Sequence<?> requiredCheckRuns, // <String>
Sequence<?> retryableLabels, String submodules, Boolean baselineFromBranch, Boolean firstParent, Boolean partialClone, String state, Object reviewStateParam, Object reviewApproversParam, Object checkerObj, Object patch, Object branch, Object describeVersion, StarlarkThread thread) throws EvalException {
checkNotEmpty(url, "url");
check(GITHUB_COM.isGitHubUrl(url), "Invalid Github URL: %s", url);
PatchTransformation patchTransformation = maybeGetPatchTransformation(patch);
String reviewStateString = convertFromNoneable(reviewStateParam, null);
Sequence<String> reviewApproversStrings = convertFromNoneable(reviewApproversParam, null);
ReviewState reviewState;
ImmutableSet<AuthorAssociation> reviewApprovers;
if (reviewStateString == null) {
reviewState = null;
check(reviewApproversStrings == null, "'review_approvers' cannot be set if `review_state` is not set");
reviewApprovers = ImmutableSet.of();
} else {
reviewState = ReviewState.valueOf(reviewStateString);
if (reviewApproversStrings == null) {
reviewApproversStrings = StarlarkList.of(/*mutability=*/
null, "COLLABORATOR", "MEMBER", "OWNER");
}
HashSet<AuthorAssociation> approvers = new HashSet<>();
for (String r : reviewApproversStrings) {
boolean added = approvers.add(stringToEnum("review_approvers", r, AuthorAssociation.class));
check(added, "Repeated element %s", r);
}
reviewApprovers = ImmutableSet.copyOf(approvers);
}
GitHubPrOriginOptions prOpts = options.get(GitHubPrOriginOptions.class);
return new GitHubPrOrigin(fixHttp(url, thread.getCallerLocation()), prOpts.overrideMerge != null ? prOpts.overrideMerge : merge, options.get(GeneralOptions.class), options.get(GitOptions.class), options.get(GitOriginOptions.class), options.get(GitHubOptions.class), prOpts, ImmutableSet.copyOf(Sequence.cast(requiredLabels, String.class, GitHubUtil.REQUIRED_LABELS)), ImmutableSet.copyOf(Sequence.cast(requiredStatusContextNames, String.class, GitHubUtil.REQUIRED_STATUS_CONTEXT_NAMES)), ImmutableSet.copyOf(Sequence.cast(requiredCheckRuns, String.class, GitHubUtil.REQUIRED_CHECK_RUNS)), ImmutableSet.copyOf(Sequence.cast(retryableLabels, String.class, GitHubUtil.RETRYABLE_LABELS)), stringToEnum("submodules", submodules, SubmoduleStrategy.class), baselineFromBranch, firstParent, partialClone, stringToEnum("state", state, StateFilter.class), reviewState, reviewApprovers, convertFromNoneable(checkerObj, null), patchTransformation, convertFromNoneable(branch, null), convertDescribeVersion(describeVersion), GITHUB_COM);
}
Aggregations