Search in sources :

Example 11 with StarlarkMethod

use of net.starlark.java.annot.StarlarkMethod in project copybara by google.

the class GitModule method origin.

@SuppressWarnings("unused")
@StarlarkMethod(name = "origin", doc = "Defines a standard Git origin. For Git specific origins use: `github_origin` or " + "`gerrit_origin`.<br><br>All the origins in this module accept several string" + " formats as reference (When copybara is called in the form of `copybara config" + " workflow reference`):<br><ul><li>**Branch name:** For example" + " `master`</li><li>**An arbitrary reference:**" + " `refs/changes/20/50820/1`</li><li>**A SHA-1:** Note that it has to be reachable" + " from the default refspec</li><li>**A Git repository URL and reference:**" + " `http://github.com/foo master`</li><li>**A GitHub pull request URL:**" + " `https://github.com/some_project/pull/1784`</li></ul><br>So for example," + " Copybara can be invoked for a `git.origin` in the CLI as:<br>`copybara" + " copy.bara.sky my_workflow https://github.com/some_project/pull/1784`<br>This" + " will use the pull request as the origin URL and reference.", parameters = { @Param(name = "url", named = true, doc = "Indicates the URL of the git repository"), @Param(name = "ref", allowedTypes = { @ParamType(type = String.class), @ParamType(type = NoneType.class) }, defaultValue = "None", named = true, doc = "Represents the default reference that will be used for reading the revision " + "from the git repository. For example: 'master'"), @Param(name = "submodules", defaultValue = "'NO'", named = true, positional = false, doc = "Download submodules. Valid values: NO, YES, RECURSIVE."), @Param(name = "include_branch_commit_logs", defaultValue = "False", named = true, positional = false, doc = "Whether to include raw logs of branch commits in the migrated change message." + "WARNING: This field is deprecated in favor of 'first_parent' one." + " This setting *only* affects merge commits."), @Param(name = "first_parent", defaultValue = "True", named = true, positional = false, 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."), @Param(name = "partial_fetch", defaultValue = "False", named = true, positional = false, doc = "If true, partially fetch git repository by only fetching affected files."), @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 = "describe_version", allowedTypes = { @ParamType(type = Boolean.class), @ParamType(type = NoneType.class) }, defaultValue = "None", named = true, positional = false, doc = DESCRIBE_VERSION_FIELD_DOC), @Param(name = "version_selector", allowedTypes = { @ParamType(type = VersionSelector.class), @ParamType(type = NoneType.class) }, defaultValue = "None", named = true, positional = false, doc = "Select a custom version (tag)to migrate" + " instead of 'ref'"), @Param(name = "primary_branch_migration", allowedTypes = { @ParamType(type = Boolean.class) }, defaultValue = "False", named = true, positional = false, doc = "When enabled, copybara will ignore the 'ref' param if it is 'master' or 'main'" + " and instead try to establish the default git branch. If this fails, it will " + "fall back to the 'ref' param.\n" + "This is intended to help migrating to the new standard of using 'main' without " + "breaking users relying on the legacy default.") }, useStarlarkThread = true)
public GitOrigin origin(String url, Object ref, String submodules, Boolean includeBranchCommitLogs, Boolean firstParent, Boolean partialFetch, Object patch, Object describeVersion, Object versionSelector, Boolean primaryBranchMigration, StarlarkThread thread) throws EvalException {
    checkNotEmpty(url, "url");
    PatchTransformation patchTransformation = maybeGetPatchTransformation(patch);
    if (versionSelector != Starlark.NONE) {
        check(ref == Starlark.NONE, "Cannot use ref field and version_selector. Version selector will decide the ref" + " to migrate");
    }
    return GitOrigin.newGitOrigin(options, fixHttp(url, thread.getCallerLocation()), SkylarkUtil.convertOptionalString(ref), GitRepoType.GIT, stringToEnum("submodules", submodules, GitOrigin.SubmoduleStrategy.class), includeBranchCommitLogs, firstParent, partialFetch, primaryBranchMigration, patchTransformation, convertDescribeVersion(describeVersion), convertFromNoneable(versionSelector, null), mainConfigFile.path(), workflowName);
}
Also used : PatchTransformation(com.google.copybara.transform.patch.PatchTransformation) SubmoduleStrategy(com.google.copybara.git.GitOrigin.SubmoduleStrategy) StarlarkMethod(net.starlark.java.annot.StarlarkMethod)

Example 12 with StarlarkMethod

use of net.starlark.java.annot.StarlarkMethod in project copybara by google.

the class GitModule method versionSelector.

@SuppressWarnings("unused")
@StarlarkMethod(name = "latest_version", doc = "Customize what version of the available branches and tags to pick." + " By default it ignores the reference passed as parameter. Using `force:reference`" + " in the CLI will force to use that reference instead.", parameters = { @Param(name = "refspec_format", doc = "The format of the branch/tag", named = true, defaultValue = "\"refs/tags/${n0}.${n1}.${n2}\""), @Param(name = "refspec_groups", named = true, doc = "A set of named regexes that can be used to match part of the versions. Copybara" + " uses [re2](https://github.com/google/re2/wiki/Syntax) syntax. Use the" + " following nomenclature n0, n1, n2 for the version part (will use numeric" + " sorting) or s0, s1, s2 (alphabetic sorting). Note that there can be mixed" + " but the numbers cannot be repeated. In other words n0, s1, n2 is valid but" + " not n0, s0, n1. n0 has more priority than n1. If there are fields where" + " order is not important, use s(N+1) where N ist he latest sorted field." + " Example {\"n0\": \"[0-9]+\", \"s1\": \"[a-z]+\"}", defaultValue = "{'n0' : '[0-9]+', 'n1' : '[0-9]+', 'n2' : '[0-9]+'}") }, useStarlarkThread = true)
public LatestVersionSelector versionSelector(String refspec, Dict<?, ?> groups, // <String, String>
StarlarkThread thread) throws EvalException {
    Map<String, String> groupsMap = Dict.cast(groups, String.class, String.class, "refspec_groups");
    check(refspec.startsWith("refs/"), "Wrong value '%s'. Refspec has to" + " start with 'refs/'. For example 'refs/tags/${v0}.${v1}.${v2}'", refspec);
    TreeMap<Integer, VersionElementType> elements = new TreeMap<>();
    Pattern regexKey = Pattern.compile("([sn])([0-9])");
    for (String s : groupsMap.keySet()) {
        Matcher matcher = regexKey.matcher(s);
        check(matcher.matches(), "Incorrect key for refspec_group. Should be in the " + "format of n0, n1, etc. or s0, s1, etc. Value: %s", s);
        VersionElementType type = matcher.group(1).equals("s") ? ALPHABETIC : NUMERIC;
        int num = Integer.parseInt(matcher.group(2));
        check(!elements.containsKey(num) || elements.get(num) == type, "Cannot use same n in both s%s and n%s: %s", num, num, s);
        elements.put(num, type);
    }
    for (Integer num : elements.keySet()) {
        if (num > 0) {
            check(elements.containsKey(num - 1), "Cannot have s%s or n%s if s%s or n%s" + " doesn't exist", num, num, num - 1, num - 1);
        }
    }
    LatestVersionSelector versionPicker = new LatestVersionSelector(refspec, Replace.parsePatterns(groupsMap), elements, thread.getCallerLocation());
    ImmutableList<String> extraGroups = versionPicker.getUnmatchedGroups();
    check(extraGroups.isEmpty(), "Extra refspec_groups not used in pattern: %s", extraGroups);
    return versionPicker;
}
Also used : Pattern(com.google.re2j.Pattern) VersionElementType(com.google.copybara.git.LatestVersionSelector.VersionElementType) Matcher(com.google.re2j.Matcher) TreeMap(java.util.TreeMap) StarlarkMethod(net.starlark.java.annot.StarlarkMethod)

Example 13 with StarlarkMethod

use of net.starlark.java.annot.StarlarkMethod 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/&lt;ID&gt;/merge should be used instead of the PR" + " head. The GitOrigin-RevId still will be the one from" + " refs/pull/&lt;ID&gt;/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);
}
Also used : PatchTransformation(com.google.copybara.transform.patch.PatchTransformation) StateFilter(com.google.copybara.git.GitHubPrOrigin.StateFilter) GeneralOptions(com.google.copybara.GeneralOptions) SubmoduleStrategy(com.google.copybara.git.GitOrigin.SubmoduleStrategy) ReviewState(com.google.copybara.git.GitHubPrOrigin.ReviewState) AuthorAssociation(com.google.copybara.git.github.api.AuthorAssociation) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) StarlarkMethod(net.starlark.java.annot.StarlarkMethod) UsesFlags(com.google.copybara.doc.annotations.UsesFlags) DocDefault(com.google.copybara.doc.annotations.DocDefault)

Example 14 with StarlarkMethod

use of net.starlark.java.annot.StarlarkMethod in project copybara by google.

the class GitModule method gerritOrigin.

@SuppressWarnings("unused")
@StarlarkMethod(name = "gerrit_origin", doc = "Defines a Git origin for Gerrit reviews.\n" + "\n" + "Implicit labels that can be used/exposed:\n" + "\n" + "  - " + GerritChange.GERRIT_CHANGE_NUMBER_LABEL + ": The change number for the Gerrit review.\n" + "  - " + GerritChange.GERRIT_CHANGE_ID_LABEL + ": The change id for the Gerrit review.\n" + "  - " + GerritChange.GERRIT_CHANGE_DESCRIPTION_LABEL + ": The description of the Gerrit review.\n" + "  - " + DEFAULT_INTEGRATE_LABEL + ": A label that when exposed, can be used to" + " integrate automatically in the reverse workflow.\n" + "  - " + GerritChange.GERRIT_CHANGE_BRANCH + ": The destination branch for thechange\n" + "  - " + GerritChange.GERRIT_CHANGE_TOPIC + ": The change topic\n" + "  - " + GerritChange.GERRIT_COMPLETE_CHANGE_ID_LABEL + ": Complete Change-Id with project, branch and Change-Id\n" + "  - " + GerritChange.GERRIT_OWNER_EMAIL_LABEL + ": Owner email\n" + "  - GERRIT_REVIEWER_EMAIL: Multiple value field with the email of the reviewers\n" + "  - GERRIT_CC_EMAIL: Multiple value field with the email of the people/groups in" + " cc\n", parameters = { @Param(name = "url", named = true, doc = "Indicates the URL of the git repository"), @Param(name = "ref", allowedTypes = { @ParamType(type = String.class), @ParamType(type = NoneType.class) }, defaultValue = "None", named = true, doc = "DEPRECATED. Use git.origin for submitted branches."), @Param(name = "submodules", defaultValue = "'NO'", named = true, doc = "Download submodules. Valid values: NO, YES, RECURSIVE."), @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 = "If true, partially fetch git repository by only fetching affected files.."), @Param(name = "api_checker", allowedTypes = { @ParamType(type = Checker.class), @ParamType(type = NoneType.class) }, defaultValue = "None", doc = "A checker for the Gerrit 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) }, defaultValue = "None", named = true, positional = false, doc = "Limit the import to" + " changes that are for this branch. By default imports everything."), @Param(name = "describe_version", allowedTypes = { @ParamType(type = Boolean.class), @ParamType(type = NoneType.class) }, defaultValue = "None", named = true, positional = false, doc = DESCRIBE_VERSION_FIELD_DOC), @Param(name = "ignore_gerrit_noop", defaultValue = "False", named = true, positional = false, doc = "Option to not migrate Gerrit changes that do not change origin_files"), @Param(name = "primary_branch_migration", allowedTypes = { @ParamType(type = Boolean.class) }, defaultValue = "False", named = true, positional = false, doc = "When enabled, copybara will ignore the 'ref' param if it is 'master' or 'main'" + " and instead try to establish the default git branch. If this fails, it will " + "fall back to the 'ref' param.\n" + "This is intended to help migrating to the new standard of using 'main' without " + "breaking users relying on the legacy default.") }, useStarlarkThread = true)
public GitOrigin gerritOrigin(String url, Object ref, String submodules, Boolean firstParent, Boolean partialFetch, Object checkerObj, Object patch, Object branch, Object describeVersion, Boolean ignoreGerritNoop, Boolean primaryBranchMigration, StarlarkThread thread) throws EvalException {
    checkNotEmpty(url, "url");
    url = fixHttp(url, thread.getCallerLocation());
    String refField = SkylarkUtil.convertOptionalString(ref);
    PatchTransformation patchTransformation = maybeGetPatchTransformation(patch);
    if (!Strings.isNullOrEmpty(refField)) {
        getGeneralConsole().warn("'ref' field detected in configuration. git.gerrit_origin" + " is deprecating its usage for submitted changes. Use git.origin instead.");
        return GitOrigin.newGitOrigin(options, url, refField, GitRepoType.GERRIT, stringToEnum("submodules", submodules, GitOrigin.SubmoduleStrategy.class), /*includeBranchCommitLogs=*/
        false, firstParent, partialFetch, primaryBranchMigration, patchTransformation, convertDescribeVersion(describeVersion), /*versionSelector=*/
        null, mainConfigFile.path(), workflowName);
    }
    return GerritOrigin.newGerritOrigin(options, url, stringToEnum("submodules", submodules, GitOrigin.SubmoduleStrategy.class), firstParent, partialFetch, convertFromNoneable(checkerObj, null), patchTransformation, convertFromNoneable(branch, null), convertDescribeVersion(describeVersion), ignoreGerritNoop, primaryBranchMigration);
}
Also used : PatchTransformation(com.google.copybara.transform.patch.PatchTransformation) SubmoduleStrategy(com.google.copybara.git.GitOrigin.SubmoduleStrategy) StarlarkMethod(net.starlark.java.annot.StarlarkMethod)

Example 15 with StarlarkMethod

use of net.starlark.java.annot.StarlarkMethod in project copybara by google.

the class GitModule method gerritTrigger.

@SuppressWarnings("unused")
@StarlarkMethod(name = GERRIT_TRIGGER, doc = "Defines a feedback trigger based on updates on a Gerrit change.", parameters = { @Param(name = "url", doc = "Indicates the Gerrit repo URL.", named = true), @Param(name = "checker", allowedTypes = { @ParamType(type = Checker.class), @ParamType(type = NoneType.class) }, defaultValue = "None", doc = "A checker for the Gerrit API transport provided by this trigger.", named = true) }, useStarlarkThread = true)
@UsesFlags(GerritOptions.class)
public GerritTrigger gerritTrigger(String url, Object checkerObj, StarlarkThread thread) throws EvalException {
    checkNotEmpty(url, "url");
    url = fixHttp(url, thread.getCallerLocation());
    Checker checker = convertFromNoneable(checkerObj, null);
    validateEndpointChecker(checker, GERRIT_TRIGGER);
    GerritOptions gerritOptions = options.get(GerritOptions.class);
    return new GerritTrigger(gerritOptions.newGerritApiSupplier(url, checker), url, getGeneralConsole());
}
Also used : Checker(com.google.copybara.checks.Checker) StarlarkMethod(net.starlark.java.annot.StarlarkMethod) UsesFlags(com.google.copybara.doc.annotations.UsesFlags)

Aggregations

StarlarkMethod (net.starlark.java.annot.StarlarkMethod)37 UsesFlags (com.google.copybara.doc.annotations.UsesFlags)17 DocDefault (com.google.copybara.doc.annotations.DocDefault)9 Checker (com.google.copybara.checks.Checker)8 Example (com.google.copybara.doc.annotations.Example)8 GeneralOptions (com.google.copybara.GeneralOptions)7 ValidationException (com.google.copybara.exception.ValidationException)7 Pattern (com.google.re2j.Pattern)6 SubmoduleStrategy (com.google.copybara.git.GitOrigin.SubmoduleStrategy)4 PatchTransformation (com.google.copybara.transform.patch.PatchTransformation)4 ImmutableList (com.google.common.collect.ImmutableList)3 LabelsAwareModule (com.google.copybara.config.LabelsAwareModule)3 SkylarkTransformation (com.google.copybara.transform.SkylarkTransformation)3 Transformations.toTransformation (com.google.copybara.transform.Transformations.toTransformation)3 IOException (java.io.IOException)3 Module (net.starlark.java.eval.Module)3 Action (com.google.copybara.action.Action)2 StarlarkAction (com.google.copybara.action.StarlarkAction)2 RepoException (com.google.copybara.exception.RepoException)2 FolderModule (com.google.copybara.folder.FolderModule)2