Search in sources :

Example 16 with UsesFlags

use of com.google.copybara.doc.annotations.UsesFlags in project copybara by google.

the class RemoteFileModule method remoteArchiveOrigin.

@StarlarkMethod(name = "origin", doc = "Defines a remote file origin. This is a WIP and experimental. Do not use. ", parameters = { @Param(name = "unpack_method", defaultValue = "None", doc = "The method by which to unpack the remote file. Currently 'zip' allowed. 'tar' and" + " 'as-is' to be added soon.", named = true), @Param(name = "author", defaultValue = "'Copybara <noreply@copybara.io>'", doc = "Author to attribute the change to", named = true), // TODO(joshgoldman): support labels in addition to message
@Param(name = "message", defaultValue = "'Placeholder message'", doc = "Message to attach to the change", named = true) })
@UsesFlags(RemoteFileOptions.class)
public RemoteArchiveOrigin remoteArchiveOrigin(String fileType, String author, String message) throws EvalException, ValidationException {
    GeneralOptions generalOptions = options.get(GeneralOptions.class);
    RemoteFileOptions remoteFileOptions = options.get(RemoteFileOptions.class);
    return new RemoteArchiveOrigin(fileType, Author.parse(author), message, remoteFileOptions.getTransport(), generalOptions.profiler(), remoteFileOptions);
}
Also used : GeneralOptions(com.google.copybara.GeneralOptions) StarlarkMethod(net.starlark.java.annot.StarlarkMethod) UsesFlags(com.google.copybara.doc.annotations.UsesFlags)

Example 17 with UsesFlags

use of com.google.copybara.doc.annotations.UsesFlags in project copybara by google.

the class PatchModule method quiltApply.

@SuppressWarnings("unused")
@StarlarkMethod(name = "quilt_apply", doc = "A transformation that applies and updates patch files using Quilt. Compared to" + " `patch.apply`, this transformation supports updating the content of patch files" + " if they can be successfully applied with fuzz. The patch files must be included" + " in the destination_files glob in order to get updated. Underneath, Copybara" + " runs `quilt import; quilt push; quilt refresh` for each patch file in the" + " `series` file in order. Currently, all patch files and the `series` file must" + " reside in a \"patches\" sub-directory under the root directory containing the" + " migrated code. This means it has the limitation that the migrated code itself" + " cannot contain a directory with the name \"patches\".", parameters = { @Param(name = "series", named = true, positional = false, doc = "A file which contains a list of patches to apply. It is similar to the `series`" + " parameter in `patch.apply` transformation, and is required for Quilt." + " Patches listed in this file will be applied relative to the checkout dir," + " and the leading path component is stripped via the `-p1` flag. Currently" + " this file should be the `patches/series` file in the root directory" + " of the migrated code.") }, useStarlarkThread = true)
@Example(title = "Workflow to apply and update patches", before = "Suppose the destination repository's directory structure looks like:\n" + "```\n" + "source_root/BUILD\n" + "source_root/copy.bara.sky\n" + "source_root/migrated_file1\n" + "source_root/migrated_file2\n" + "source_root/patches/series\n" + "source_root/patches/patch1.patch\n" + "```\n" + "Then the transformations in `source_root/copy.bara.sky` should look like:", code = "[\n" + "    patch.quilt_apply(series = \"patches/series\"),\n" + "    core.move(\"\", \"source_root\"),\n" + "]", after = "In this example, `patch1.patch` is applied to `migrated_file1` and/or `migrated_file2`." + " `patch1.patch` itself will be updated during the migration if it is applied with" + " fuzz.")
@UsesFlags(PatchingOptions.class)
public QuiltTransformation quiltApply(String series, StarlarkThread thread) throws EvalException {
    ImmutableList.Builder<ConfigFile> builder = ImmutableList.builder();
    ConfigFile seriesFile = parseSeries(series, builder);
    return new QuiltTransformation(seriesFile, builder.build(), patchingOptions, /*reverse=*/
    false, thread.getCallerLocation());
}
Also used : ConfigFile(com.google.copybara.config.ConfigFile) ImmutableList(com.google.common.collect.ImmutableList) StarlarkMethod(net.starlark.java.annot.StarlarkMethod) UsesFlags(com.google.copybara.doc.annotations.UsesFlags) Example(com.google.copybara.doc.annotations.Example)

Aggregations

UsesFlags (com.google.copybara.doc.annotations.UsesFlags)17 StarlarkMethod (net.starlark.java.annot.StarlarkMethod)16 Checker (com.google.copybara.checks.Checker)8 GeneralOptions (com.google.copybara.GeneralOptions)7 DocDefault (com.google.copybara.doc.annotations.DocDefault)5 LabelsAwareModule (com.google.copybara.config.LabelsAwareModule)3 Example (com.google.copybara.doc.annotations.Example)3 Module (net.starlark.java.eval.Module)3 Action (com.google.copybara.action.Action)2 StarlarkAction (com.google.copybara.action.StarlarkAction)2 FolderModule (com.google.copybara.folder.FolderModule)2 LinkedHashSet (java.util.LinkedHashSet)2 Parameter (com.beust.jcommander.Parameter)1 ImmutableList (com.google.common.collect.ImmutableList)1 WorkflowOptions (com.google.copybara.WorkflowOptions)1 Author (com.google.copybara.authoring.Author)1 Authoring (com.google.copybara.authoring.Authoring)1 ConfigFile (com.google.copybara.config.ConfigFile)1 DocElement (com.google.copybara.doc.annotations.DocElement)1 NonReversibleValidationException (com.google.copybara.exception.NonReversibleValidationException)1