Search in sources :

Example 1 with DefaultWriteHook

use of com.google.copybara.git.GitDestination.WriterImpl.DefaultWriteHook in project copybara by google.

the class GitModule method destination.

@SuppressWarnings("unused")
@StarlarkMethod(name = "destination", doc = "Creates a commit in a git repository using the transformed worktree.<br><br>For" + " GitHub use git.github_destination. For creating Pull Requests in GitHub, use" + " git.github_pr_destination. For creating a Gerrit change use" + " git.gerrit_destination.<br><br>Given that Copybara doesn't ask" + " for user/password in the console when doing the push to remote repos, you have to" + " use ssh protocol, have the credentials cached or use a credential manager.", parameters = { @Param(name = "url", named = true, doc = "Indicates the URL to push to as well as the URL from which to get the parent " + "commit"), @Param(name = "push", named = true, doc = "Reference to use for pushing the change, for example 'main'.", defaultValue = "'master'"), @Param(name = "tag_name", allowedTypes = { @ParamType(type = String.class), @ParamType(type = NoneType.class) }, named = true, doc = "A template string that refers to a tag name. If tag_name exists, overwrite " + "this tag only if flag git-tag-overwrite is set. Note that tag creation is " + "best-effort and migration will succeed even if the tag cannot be created. " + "Usage: Users can use a string or a string with a label. " + "For instance ${label}_tag_name. And the value of label must be " + "in changes' label list. Otherwise, tag won't be created.", defaultValue = "None"), @Param(name = "tag_msg", allowedTypes = { @ParamType(type = String.class), @ParamType(type = NoneType.class) }, named = true, doc = "A template string that refers to the commit msg of a tag. If set, we will " + "create an annotated tag when tag_name is set. Usage: Users can use a string " + "or a string with a label. For instance ${label}_message. And the value of " + "label must be in changes' label list. Otherwise, tag will be created with " + "sha1's commit msg.", defaultValue = "None"), @Param(name = "fetch", allowedTypes = { @ParamType(type = String.class), @ParamType(type = NoneType.class) }, named = true, doc = "Indicates the ref from which to get the parent commit. Defaults to push value" + " if None", defaultValue = "None"), @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 = "integrates", named = true, allowedTypes = { @ParamType(type = Sequence.class, generic1 = GitIntegrateChanges.class), @ParamType(type = NoneType.class) }, defaultValue = "None", doc = "Integrate changes from a url present in the migrated change" + " label. Defaults to a semi-fake merge if COPYBARA_INTEGRATE_REVIEW label is" + " present in the message", positional = false), @Param(name = "primary_branch_migration", allowedTypes = { @ParamType(type = Boolean.class) }, defaultValue = "False", named = true, positional = false, doc = "When enabled, copybara will ignore the 'push' and 'fetch' params if either is" + " 'master' or 'main' and instead try to establish the default git branch. If" + " this fails, it will fall back to the param's declared value.\n" + "This is intended to help migrating to the new standard of using 'main'" + " without breaking users relying on the legacy default."), @Param(name = "checker", allowedTypes = { @ParamType(type = Checker.class), @ParamType(type = NoneType.class) }, defaultValue = "None", doc = "A checker that can check leaks or other checks in the commit created. ", named = true, positional = false) }, useStarlarkThread = true)
@UsesFlags(GitDestinationOptions.class)
public GitDestination destination(String url, String push, Object tagName, Object tagMsg, Object fetch, boolean partialFetch, Object integrates, Boolean primaryBranchMigration, Object checker, StarlarkThread thread) throws EvalException {
    GitDestinationOptions destinationOptions = options.get(GitDestinationOptions.class);
    String resolvedPush = checkNotEmpty(firstNotNull(destinationOptions.push, push), "push");
    GeneralOptions generalOptions = options.get(GeneralOptions.class);
    Checker maybeChecker = convertFromNoneable(checker, null);
    if (maybeChecker != null && options.get(GitDestinationOptions.class).skipGitChecker) {
        maybeChecker = null;
        getGeneralConsole().warn("Skipping git checker for git.destination. Note that this could" + " cause leaks or other problems");
    }
    return new GitDestination(fixHttp(checkNotEmpty(firstNotNull(destinationOptions.url, url), "url"), thread.getCallerLocation()), checkNotEmpty(firstNotNull(destinationOptions.fetch, convertFromNoneable(fetch, null), resolvedPush), "fetch"), resolvedPush, partialFetch, primaryBranchMigration, convertFromNoneable(tagName, null), convertFromNoneable(tagMsg, null), destinationOptions, options.get(GitOptions.class), generalOptions, new DefaultWriteHook(), Starlark.isNullOrNone(integrates) ? defaultGitIntegrate : Sequence.cast(integrates, GitIntegrateChanges.class, "integrates"), maybeChecker);
}
Also used : DefaultWriteHook(com.google.copybara.git.GitDestination.WriterImpl.DefaultWriteHook) GeneralOptions(com.google.copybara.GeneralOptions) Checker(com.google.copybara.checks.Checker) StarlarkMethod(net.starlark.java.annot.StarlarkMethod) UsesFlags(com.google.copybara.doc.annotations.UsesFlags)

Aggregations

GeneralOptions (com.google.copybara.GeneralOptions)1 Checker (com.google.copybara.checks.Checker)1 UsesFlags (com.google.copybara.doc.annotations.UsesFlags)1 DefaultWriteHook (com.google.copybara.git.GitDestination.WriterImpl.DefaultWriteHook)1 StarlarkMethod (net.starlark.java.annot.StarlarkMethod)1