├── external └── third_party │ ├── BUILD │ └── jcommander.BUILD ├── .gitignore ├── cloudbuild.sh ├── .bazelproject ├── third_party ├── bazel │ ├── BUILD │ ├── bashunit │ │ └── BUILD │ └── main │ │ └── java │ │ └── com │ │ └── google │ │ └── copybara │ │ └── shell │ │ ├── ExecFailedException.java │ │ ├── ProcessKillable.java │ │ └── Killable.java ├── bazel.bzl ├── bazel_skylib.bzl └── bazel_buildtools.bzl ├── AUTHORS ├── java └── com │ └── google │ └── copybara │ ├── git │ ├── github │ │ └── api │ │ │ ├── testing │ │ │ ├── update_reference_response_testdata.json │ │ │ ├── get_reference_response_testdata.json │ │ │ ├── labels_response_testdata.json │ │ │ ├── get_all_references_response_testdata.json │ │ │ ├── get_authenticated_user_response_testdata.json │ │ │ ├── user_permission_level_testdata.json │ │ │ ├── lsremote_testdata.json │ │ │ └── BUILD │ │ │ ├── AuthorAssociation.java │ │ │ ├── PaginatedPayload.java │ │ │ ├── CommentBody.java │ │ │ ├── Label.java │ │ │ ├── AddAssignees.java │ │ │ └── AddLabels.java │ ├── gerritapi │ │ ├── Empty.java │ │ ├── ProjectInput.java │ │ ├── NotifyType.java │ │ ├── GerritEventType.java │ │ ├── SubmitRequirementExpressionStatus.java │ │ ├── ChangeStatus.java │ │ ├── SubmitRequirementResultStatus.java │ │ ├── ReviewerInput.java │ │ ├── DeleteReviewerInput.java │ │ ├── SubmitInput.java │ │ ├── IncludeResult.java │ │ ├── DeleteVoteInput.java │ │ └── RestoreInput.java │ ├── GitMirrorOptions.java │ ├── RebaseConflictException.java │ ├── InvalidRefspecException.java │ ├── CannotIntegrateException.java │ ├── testing │ │ └── BUILD │ ├── EventTrigger.java │ └── GerritEventTrigger.java │ ├── Option.java │ ├── util │ ├── console │ │ ├── StarlarkMode.java │ │ ├── AnsiEscapes.java │ │ ├── BUILD │ │ ├── testing │ │ │ └── BUILD │ │ ├── EnhancedPredicate.java │ │ └── AnsiColor.java │ ├── RepositoryUtil.java │ └── SettableSupplier.java │ ├── remotefile │ ├── extractutil │ │ ├── ExtractType.java │ │ └── BUILD │ ├── HttpStreamFactory.java │ ├── RemoteArchiveVersionSelector.java │ └── RemoteArchiveVersion.java │ ├── json │ └── BUILD │ ├── http │ ├── testing │ │ └── BUILD │ ├── json │ │ └── BUILD │ ├── auth │ │ └── BUILD │ ├── multipart │ │ └── BUILD │ ├── HttpOptions.java │ ├── endpoint │ │ ├── BUILD │ │ └── HttpEndpointBody.java │ └── HttpTrigger.java │ ├── configgen │ └── BUILD │ ├── buildozer │ ├── TargetNotFoundException.java │ └── testing │ │ └── BUILD │ ├── exception │ ├── ChangeRejectedException.java │ ├── BUILD │ ├── RepoException.java │ ├── CommandLineException.java │ ├── VoidOperationException.java │ ├── NotADestinationFileException.java │ ├── CannotResolveLabel.java │ ├── CannotResolveRevisionException.java │ ├── EmptyChangeException.java │ ├── AccessValidationException.java │ └── NonReversibleValidationException.java │ ├── DestinationInfo.java │ ├── re2 │ └── BUILD │ ├── python │ └── BUILD │ ├── profiler │ ├── BUILD │ └── Listener.java │ ├── starlark │ ├── BUILD │ └── StarlarkUtil.java │ ├── hg │ └── testing │ │ ├── BUILD │ │ └── HgTesting.java │ ├── xml │ └── BUILD │ ├── onboard │ ├── core │ │ ├── BUILD │ │ ├── CannotConvertException.java │ │ ├── CannotProvideException.java │ │ └── Converter.java │ ├── ConfigFieldPopulator.java │ └── ConfigTemplate.java │ ├── html │ └── BUILD │ ├── testing │ ├── profiler │ │ └── BUILD │ └── DummyTrigger.java │ ├── authoring │ ├── BUILD │ └── InvalidAuthorException.java │ ├── effect │ └── BUILD │ ├── hashing │ └── BUILD │ ├── revision │ └── BUILD │ ├── templatetoken │ └── BUILD │ ├── checks │ ├── BUILD │ └── CheckerException.java │ ├── credentials │ ├── Credential.java │ ├── CredentialIssuingException.java │ ├── CredentialRetrievalException.java │ ├── BUILD │ ├── CredentialOptions.java │ └── CredentialIssuer.java │ ├── toml │ └── BUILD │ ├── doc │ └── annotations │ │ ├── DocDefaults.java │ │ ├── Examples.java │ │ ├── Library.java │ │ ├── DocSignaturePrefix.java │ │ └── DocDefault.java │ ├── ConfigLoaderProvider.java │ ├── compression │ └── BUILD │ ├── approval │ ├── NoneApprovedProvider.java │ └── BUILD │ ├── version │ ├── VersionResolver.java │ ├── BUILD │ └── RequestedVersionSelector.java │ ├── SkylarkContext.java │ ├── config │ └── OptionsAwareModule.java │ ├── jcommander │ ├── SemicolonSeparatedListSplitter.java │ ├── GreaterThanZeroValidator.java │ └── MapConverter.java │ ├── archive │ └── BUILD │ ├── monitor │ └── BUILD │ ├── transform │ ├── debug │ │ └── BUILD │ └── ReversibleFunction.java │ ├── CopybaraCmd.java │ ├── Trigger.java │ └── format │ └── BuildifierOptions.java ├── BUILD ├── scripts └── update_docs ├── copybara └── integration │ ├── hello.t │ └── BUILD ├── javatests └── com │ └── google │ └── copybara │ ├── python │ ├── testfiles │ │ └── TESTMETADATA │ └── BUILD │ ├── exception │ └── BUILD │ ├── templatetoken │ └── BUILD │ ├── compression │ └── BUILD │ ├── config │ └── base │ │ └── BUILD │ ├── configgen │ └── BUILD │ ├── remotefile │ └── extractutil │ │ └── BUILD │ ├── util │ └── console │ │ ├── testing │ │ └── BUILD │ │ └── BUILD │ ├── hashing │ └── BUILD │ ├── json │ └── BUILD │ ├── xml │ └── BUILD │ ├── re2 │ └── BUILD │ ├── html │ └── BUILD │ ├── checks │ └── BUILD │ ├── http │ ├── BUILD │ ├── json │ │ └── BUILD │ ├── auth │ │ └── BUILD │ ├── endpoint │ │ └── BUILD │ └── multipart │ │ └── BUILD │ ├── toml │ └── BUILD │ ├── archive │ └── BUILD │ ├── profiler │ └── BUILD │ ├── transform │ └── debug │ │ └── BUILD │ ├── git │ └── github │ │ └── util │ │ └── BUILD │ ├── credentials │ └── BUILD │ ├── onboard │ └── core │ │ └── BUILD │ ├── monitor │ └── BUILD │ ├── buildozer │ └── BUILD │ └── version │ └── BUILD ├── ci └── ubuntu │ ├── continuous.cfg │ └── continuous.sh ├── docs └── BUILD ├── ci.Dockerfile ├── WORKSPACE ├── cloudbuild.yaml ├── .bazelrc ├── .docker └── copybara ├── CONTRIBUTING.md ├── cloudbuild_setup.sh └── repositories.go.bzl /external/third_party/BUILD: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | bazel-* 2 | .idea 3 | *.iml 4 | *.pyc 5 | .ijwb 6 | /.bazelrc.user 7 | -------------------------------------------------------------------------------- /cloudbuild.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | ./cloudbuild_setup.sh 4 | 5 | log "Running 'bazel $@'" 6 | time bazel "$@" 7 | 8 | log "Done" 9 | -------------------------------------------------------------------------------- /.bazelproject: -------------------------------------------------------------------------------- 1 | directories: 2 | copybara/integration 3 | java/com/google/copybara 4 | javatests/com/google/copybara 5 | third_party 6 | 7 | targets: 8 | //copybara/integration/... 9 | //java/com/google/copybara/... 10 | //javatests/com/google/copybara/... 11 | //third_party/... 12 | 13 | -------------------------------------------------------------------------------- /third_party/bazel/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) # Apache 2.0 2 | 3 | package( 4 | default_visibility = [ 5 | "//visibility:public", 6 | ], 7 | ) 8 | 9 | java_library( 10 | name = "shell", 11 | srcs = glob(["main/**/*.java"]), 12 | deps = ["@maven//:com_google_guava_guava"], 13 | ) 14 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | # This the official list of Copybara authors for copyright purposes. 2 | # This file is distinct from the CONTRIBUTORS files. 3 | # See the latter for an explanation. 4 | 5 | # Names should be added to this file as: 6 | # Name or Organization 7 | # The email address is not required for organizations. 8 | 9 | Google Inc. 10 | -------------------------------------------------------------------------------- /third_party/bazel/bashunit/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Google Inc. All Rights Reserved. 2 | 3 | package( 4 | default_visibility = ["//visibility:public"], 5 | ) 6 | 7 | licenses(["notice"]) # Apache 2.0 8 | 9 | exports_files(["LICENSE"]) 10 | 11 | filegroup( 12 | name = "bashunit", 13 | data = [ 14 | "testenv.sh", 15 | "unittest.bash", 16 | ], 17 | ) 18 | -------------------------------------------------------------------------------- /external/third_party/jcommander.BUILD: -------------------------------------------------------------------------------- 1 | package( 2 | default_visibility = ["//visibility:public"], 3 | ) 4 | JAVACOPTS = [ 5 | "-Xlint:unchecked", 6 | "-Werror:-unchecked,-rawtypes", 7 | "-Xep:CollectionIncompatibleType:OFF", 8 | ] 9 | 10 | java_library( 11 | name = "jcommander", 12 | srcs = glob(["**/src/main/**/*.java"]), 13 | javacopts = JAVACOPTS, 14 | ) 15 | -------------------------------------------------------------------------------- /java/com/google/copybara/git/github/api/testing/update_reference_response_testdata.json: -------------------------------------------------------------------------------- 1 | { 2 | "ref": "refs/heads/test", 3 | "url": "https://api.github.com/repos/octocat/Hello-World/git/refs/heads/test", 4 | "object": { 5 | "type": "commit", 6 | "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e", 7 | "url": "https://api.github.com/repos/octocat/Hello-World/git/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e" 8 | } 9 | } -------------------------------------------------------------------------------- /java/com/google/copybara/git/github/api/testing/get_reference_response_testdata.json: -------------------------------------------------------------------------------- 1 | { 2 | "ref": "refs/heads/g3", 3 | "node_id": "MDM6UmVmNjc3MjIwMTc6ZzM=", 4 | "url": "https://api.github.com/repos/octocat/Hello-World/git/refs/heads/g3", 5 | "object": { 6 | "sha": "9a2f372a62761ac378a62935c44cfcb9695d0661", 7 | "type": "commit", 8 | "url": "https://api.github.com/repos/octocat/Hello-World/git/commits/9a2f372a62761ac378a62935c44cfcb9695d0661" 9 | } 10 | } -------------------------------------------------------------------------------- /BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | -------------------------------------------------------------------------------- /scripts/update_docs: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | bazel build --java_language_version=11 --tool_java_language_version=11 --java_runtime_version=remotejdk_11 java/com/google/copybara:generate_reference 3 | mkdir -p docs 4 | cp bazel-bin/java/com/google/copybara/reference.md docs/reference.md 5 | git add docs/reference.md 6 | # If -a we ammend the current head commit 7 | if [[ $1 == '-a' ]]; then 8 | echo "Ammending current commit ($(git rev-parse HEAD))" 9 | git commit docs/reference.md --amend -C HEAD 10 | else 11 | echo "Creating a new commit" 12 | git commit docs/reference.md -m "Update reference documentation to latest version" 13 | fi 14 | -------------------------------------------------------------------------------- /java/com/google/copybara/git/github/api/testing/labels_response_testdata.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 208045946, 4 | "node_id": "MDU6TGFiZWwyMDgwNDU5NDY=", 5 | "url": "https://api.github.com/repos/google/copybara/labels/bug", 6 | "name": "bug", 7 | "description": "Something isn't working", 8 | "color": "f29513", 9 | "default": true 10 | }, 11 | { 12 | "id": 208045947, 13 | "node_id": "MDU6TGFiZWwyMDgwNDU5NDc=", 14 | "url": "https://api.github.com/repos/google/copybara/labels/enhancement", 15 | "name": "enhancement", 16 | "description": "New feature or request", 17 | "color": "a2eeef", 18 | "default": false 19 | } 20 | ] -------------------------------------------------------------------------------- /copybara/integration/hello.t: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | $ echo hello 16 | hello 17 | -------------------------------------------------------------------------------- /javatests/com/google/copybara/python/testfiles/TESTMETADATA: -------------------------------------------------------------------------------- 1 | Metadata-Version: 2.1 2 | Name: example-package-copybara 3 | Version: 0.0.1 4 | Summary: A small example package 5 | Author-email: Example Author 6 | Project-URL: Homepage, https://github.com/pypa/sampleproject 7 | Project-URL: Bug Tracker, https://github.com/pypa/sampleproject/issues 8 | Classifier: Programming Language :: Python :: 3 9 | Classifier: License :: OSI Approved :: Apache Software License 10 | Classifier: Operating System :: OS Independent 11 | Requires-Python: >=3.7 12 | Description-Content-Type: text/markdown 13 | License-File: LICENSE 14 | 15 | # Example Package 16 | 17 | This is a simple example package. -------------------------------------------------------------------------------- /ci/ubuntu/continuous.cfg: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Location of the continuous bash script in Git. 16 | build_file: "copybara/ci/ubuntu/continuous.sh" 17 | -------------------------------------------------------------------------------- /docs/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | licenses(["notice"]) 16 | 17 | package(default_visibility = ["//visibility:public"]) 18 | 19 | exports_files(["reference.md"]) 20 | -------------------------------------------------------------------------------- /ci.Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | ARG BAZEL_VERSION 16 | FROM gcr.io/bazel-public/bazel${BAZEL_VERSION} AS build 17 | COPY . . 18 | USER root 19 | RUN ./cloudbuild_setup.sh 20 | USER ubuntu 21 | -------------------------------------------------------------------------------- /ci/ubuntu/continuous.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2019 Google Inc. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | # Fail on any error. 18 | set -e 19 | # Display commands being run. 20 | set -x 21 | 22 | cd git/copybara 23 | ./cibuild.sh 24 | -------------------------------------------------------------------------------- /java/com/google/copybara/Option.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara; 18 | 19 | /** 20 | * An {@code Option} indicates a class has options usable by copybara's config system. 21 | */ 22 | public interface Option { 23 | } 24 | -------------------------------------------------------------------------------- /third_party/bazel.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | # This file is autogenerated by copybara, please do not edit. 17 | 18 | bazel_version = "47e29b7c7c37a49a3e64324a72551b1d73d803b4" 19 | bazel_sha256 = "5bbec52aae32591b27ff98e00989cab603307c6f897f399468adeaae383bb67d" 20 | -------------------------------------------------------------------------------- /third_party/bazel_skylib.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | # This file is autogenerated by copybara, please do not edit. 17 | 18 | skylib_version = "1a1ee6c2308fc474ddb57c24e0aa82c58c11de1b" 19 | skylib_sha256 = "57aac84d14e659cfc8c91d400b62a127b16a8a330cc5745c8ac70a3227b5d3cf" 20 | -------------------------------------------------------------------------------- /java/com/google/copybara/util/console/StarlarkMode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.util.console; 18 | 19 | /** 20 | * Modes for parsing config files. 21 | */ 22 | public enum StarlarkMode { 23 | LOOSE, 24 | STRICT 25 | } 26 | -------------------------------------------------------------------------------- /third_party/bazel_buildtools.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | # This file is autogenerated by copybara, please do not edit. 17 | 18 | buildtools_version = "d4c9dccdfbb18472cfd10d5d5cb6dc65de76e3af" 19 | buildtools_sha256 = "4b750978bace4d0daa0444c5bf732c215edbc5a004806525187e6eeb90945e75" 20 | -------------------------------------------------------------------------------- /java/com/google/copybara/remotefile/extractutil/ExtractType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2023 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.copybara.remotefile.extractutil; 17 | 18 | /** Supported archive types. */ 19 | public enum ExtractType { 20 | JAR, 21 | ZIP, 22 | TAR, 23 | TAR_GZ, 24 | } 25 | -------------------------------------------------------------------------------- /java/com/google/copybara/git/gerritapi/Empty.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.git.gerritapi; 18 | 19 | /** 20 | * An empty object for operations that return nothing or when we want to ignore the result. 21 | */ 22 | public class Empty { 23 | 24 | } 25 | -------------------------------------------------------------------------------- /java/com/google/copybara/git/gerritapi/ProjectInput.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.git.gerritapi; 18 | 19 | /** 20 | * See https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#project-input 21 | */ 22 | public class ProjectInput { 23 | } 24 | -------------------------------------------------------------------------------- /java/com/google/copybara/git/gerritapi/NotifyType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.git.gerritapi; 18 | 19 | /** 20 | * Type of notification to send when abandoning/deleting a review or reviewer 21 | */ 22 | public enum NotifyType { 23 | NONE, OWNER, OWNER_REVIEWERS, ALL 24 | } 25 | -------------------------------------------------------------------------------- /java/com/google/copybara/git/github/api/testing/get_all_references_response_testdata.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "ref": "refs/heads/g3", 4 | "node_id": "MDM6UmVmNjc3MjIwMTc6ZzM=", 5 | "url": "https://api.github.com/repos/octocat/Hello-World/git/refs/heads/g3", 6 | "object": { 7 | "sha": "9a2f372a62761ac378a62935c44cfcb9695d0661", 8 | "type": "commit", 9 | "url": "https://api.github.com/repos/octocat/Hello-World/git/commits/9a2f372a62761ac378a62935c44cfcb9695d0661" 10 | } 11 | }, 12 | { 13 | "ref": "refs/heads/master", 14 | "node_id": "MDM6UmVmNjc3MjIwMTc6bWFzdGVy", 15 | "url": "https://api.github.com/repos/octocat/Hello-World/git/refs/heads/master", 16 | "object": { 17 | "sha": "9a2f372a62761ac378a62935c44cfcb9695d0661", 18 | "type": "commit", 19 | "url": "https://api.github.com/repos/octocat/Hello-World/git/commits/9a2f372a62761ac378a62935c44cfcb9695d0661" 20 | } 21 | }] -------------------------------------------------------------------------------- /java/com/google/copybara/json/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | licenses(["notice"]) 16 | 17 | package(default_visibility = ["//visibility:public"]) 18 | 19 | java_library( 20 | name = "json", 21 | srcs = glob(["**/*.java"]), 22 | deps = [ 23 | "//third_party:google_http_client", 24 | "//third_party:jsr305", 25 | ], 26 | ) 27 | -------------------------------------------------------------------------------- /java/com/google/copybara/http/testing/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | package(default_visibility = ["//visibility:public"]) 16 | 17 | java_library( 18 | name = "testing", 19 | testonly = 1, 20 | srcs = glob(["**/*.java"]), 21 | deps = [ 22 | "//third_party:google_http_client", 23 | "//third_party:google_http_client_test", 24 | ], 25 | ) 26 | -------------------------------------------------------------------------------- /java/com/google/copybara/git/gerritapi/GerritEventType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.git.gerritapi; 18 | 19 | 20 | /** Type of events that we can monitor from Gerrit. */ 21 | public enum GerritEventType { 22 | UNKNOWN, // Used if we don't know the event type. 23 | 24 | LABELS, 25 | SUBMIT_REQUIREMENTS; 26 | } 27 | -------------------------------------------------------------------------------- /javatests/com/google/copybara/exception/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//javatests/com/google/copybara:test.bzl", "all_tests") 16 | 17 | licenses(["notice"]) 18 | 19 | all_tests( 20 | name = "all_tests", 21 | tests = glob(["**/*Test.java"]), 22 | deps = [ 23 | "//java/com/google/copybara/exception", 24 | "//third_party:truth", 25 | ], 26 | ) 27 | -------------------------------------------------------------------------------- /java/com/google/copybara/http/json/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Google LLC. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | package(default_visibility = ["//visibility:public"]) 16 | 17 | java_library( 18 | name = "json", 19 | srcs = glob(["**/*.java"]), 20 | deps = [ 21 | "//java/com/google/copybara/http/endpoint", 22 | "//third_party:google_http_client", 23 | "//third_party:starlark", 24 | ], 25 | ) 26 | -------------------------------------------------------------------------------- /java/com/google/copybara/git/gerritapi/SubmitRequirementExpressionStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.git.gerritapi; 18 | 19 | /** Status describing the result of evaluating the submit requirement expression. */ 20 | public enum SubmitRequirementExpressionStatus { 21 | PASS, 22 | FAIL, 23 | ERROR, 24 | NOT_EVALUATED 25 | } 26 | -------------------------------------------------------------------------------- /javatests/com/google/copybara/templatetoken/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//javatests/com/google/copybara:test.bzl", "all_tests") 16 | 17 | licenses(["notice"]) 18 | 19 | all_tests( 20 | name = "all_tests", 21 | tests = glob(["**/*Test.java"]), 22 | deps = [ 23 | "//java/com/google/copybara/templatetoken", 24 | "//third_party:truth", 25 | ], 26 | ) 27 | -------------------------------------------------------------------------------- /java/com/google/copybara/configgen/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | package(default_visibility = ["//visibility:public"]) 16 | 17 | licenses(["notice"]) 18 | 19 | java_library( 20 | name = "configgen", 21 | srcs = [ 22 | "ConfigGenHeuristics.java", 23 | ], 24 | deps = [ 25 | "//java/com/google/copybara/util", 26 | "//third_party:guava", 27 | ], 28 | ) 29 | -------------------------------------------------------------------------------- /java/com/google/copybara/util/console/AnsiEscapes.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.util.console; 18 | 19 | final class AnsiEscapes { 20 | 21 | private AnsiEscapes() { 22 | } 23 | 24 | static String oneLineUp() { 25 | return "\u001B[1A"; 26 | } 27 | 28 | static String deleteLine() { 29 | return "\u001B[2K"; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /WORKSPACE: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | workspace(name = "com_github_google_copybara") 16 | 17 | load("//:repositories.bzl", "copybara_repositories") 18 | 19 | copybara_repositories() 20 | 21 | load("//:repositories.maven.bzl", "copybara_maven_repositories") 22 | 23 | copybara_maven_repositories() 24 | 25 | load("//:repositories.go.bzl", "copybara_go_repositories") 26 | 27 | copybara_go_repositories() 28 | -------------------------------------------------------------------------------- /java/com/google/copybara/buildozer/TargetNotFoundException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.buildozer; 18 | 19 | /** Error thrown when a target couldn't be found during a Buildozer transformation */ 20 | public class TargetNotFoundException extends Exception { 21 | 22 | TargetNotFoundException(String msg) { 23 | super(msg); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /java/com/google/copybara/exception/ChangeRejectedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.exception; 18 | 19 | 20 | /** User rejected the change and aborted execution. */ 21 | public class ChangeRejectedException extends ValidationException { 22 | 23 | public ChangeRejectedException(String message) { 24 | super(message); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /java/com/google/copybara/git/gerritapi/ChangeStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.git.gerritapi; 18 | 19 | /** 20 | * Change status for Changes as defined in 21 | * https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#change-info 22 | */ 23 | public enum ChangeStatus { 24 | NEW, 25 | MERGED, 26 | ABANDONED 27 | } 28 | -------------------------------------------------------------------------------- /cloudbuild.yaml: -------------------------------------------------------------------------------- 1 | # GCB configuration file 2 | # To learn more about GCB, go to https://cloud.google.com/container-builder/docs/ 3 | steps: 4 | - name: 'gcr.io/cloud-builders/docker:latest' 5 | args: 6 | - "build" 7 | - "-f" 8 | - "ci.Dockerfile" 9 | - "--build-arg" 10 | - "BAZEL_VERSION=@sha256:${_BAZEL_SHA256}" 11 | - "-t" 12 | - "ci" 13 | - "." 14 | # The /builder folder is mounted across steps but owned by root:root 15 | # HOME=/builder/home 16 | # https://github.com/GoogleCloudPlatform/cloud-builders/issues/641 17 | - name: 'ubuntu' 18 | args: ["chmod", "-R", "777", "/builder"] 19 | - name: 'ci' 20 | args: ["test", "--java_language_version=11", "--tool_java_language_version=11", "--java_runtime_version=remotejdk_11", "--test_output=errors", "--subcommands", "--sandbox_tmpfs_path=/tmp", "--jobs=1000", "--", "..."] 21 | options: 22 | machine_type: N1_HIGHCPU_32 23 | substitutions: 24 | _BAZEL_SHA256: 0a9fb6c7bb0db386888a26940e87829ffad4d2a6bc12bcc32523670ef9ea6505 25 | timeout: 30m 26 | -------------------------------------------------------------------------------- /java/com/google/copybara/DestinationInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara; 18 | 19 | /** 20 | * An object that is used by destinations to store data that consists of complex values. 21 | * 22 | *

Normally, values could be passed to destinations using labels, but the values can only be 23 | * strings. 24 | */ 25 | public interface DestinationInfo {} 26 | -------------------------------------------------------------------------------- /java/com/google/copybara/git/gerritapi/SubmitRequirementResultStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.git.gerritapi; 18 | 19 | /** Status describing the result of evaluating the submit requirement. */ 20 | public enum SubmitRequirementResultStatus { 21 | SATISFIED, 22 | UNSATISFIED, 23 | OVERRIDDEN, 24 | NOT_APPLICABLE, 25 | ERROR, 26 | FORCED 27 | } 28 | -------------------------------------------------------------------------------- /java/com/google/copybara/http/auth/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | package(default_visibility = ["//visibility:public"]) 16 | 17 | java_library( 18 | name = "auth", 19 | srcs = glob(["*.java"]), 20 | deps = [ 21 | "//java/com/google/copybara/credentials", 22 | "//third_party:google_http_client", 23 | "//third_party:guava", 24 | "//third_party:starlark", 25 | ], 26 | ) 27 | -------------------------------------------------------------------------------- /java/com/google/copybara/re2/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | licenses(["notice"]) 16 | 17 | package(default_visibility = ["//visibility:public"]) 18 | 19 | java_library( 20 | name = "re2", 21 | srcs = glob(["**/*.java"]), 22 | deps = [ 23 | "//java/com/google/copybara/doc:annotations", # Used for doc generation 24 | "//third_party:re2j", 25 | "//third_party:starlark", 26 | ], 27 | ) 28 | -------------------------------------------------------------------------------- /javatests/com/google/copybara/compression/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//javatests/com/google/copybara:test.bzl", "all_tests") 16 | 17 | licenses(["notice"]) 18 | 19 | all_tests( 20 | name = "all_tests", 21 | tests = glob(["*.java"]), 22 | deps = [ 23 | "//java/com/google/copybara/exception", 24 | "//java/com/google/copybara/testing", 25 | "//third_party:truth", 26 | ], 27 | ) 28 | -------------------------------------------------------------------------------- /javatests/com/google/copybara/config/base/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//javatests/com/google/copybara:test.bzl", "all_tests") 16 | 17 | licenses(["notice"]) 18 | 19 | all_tests( 20 | name = "all_tests", 21 | tests = glob(["**/*Test.java"]), 22 | deps = [ 23 | "//java/com/google/copybara/config:base", 24 | "//third_party:starlark", 25 | "//third_party:truth", 26 | ], 27 | ) 28 | -------------------------------------------------------------------------------- /java/com/google/copybara/git/GitMirrorOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.git; 18 | 19 | import com.beust.jcommander.Parameters; 20 | import com.google.copybara.Option; 21 | 22 | /** 23 | * Arguments for git.mirror migration. 24 | */ 25 | @Parameters(separators = "=") 26 | public class GitMirrorOptions implements Option { 27 | 28 | public GitMirrorOptions() {} 29 | } 30 | -------------------------------------------------------------------------------- /java/com/google/copybara/python/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | licenses(["notice"]) 16 | 17 | package(default_visibility = ["//visibility:public"]) 18 | 19 | java_library( 20 | name = "python", 21 | srcs = glob(["*.java"]), 22 | deps = [ 23 | "//java/com/google/copybara:base", 24 | "//third_party:guava", 25 | "//third_party:starlark", 26 | "//third_party:sun_mail", 27 | ], 28 | ) 29 | -------------------------------------------------------------------------------- /javatests/com/google/copybara/configgen/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//javatests/com/google/copybara:test.bzl", "all_tests") 16 | 17 | licenses(["notice"]) 18 | 19 | all_tests( 20 | name = "all_tests", 21 | tests = glob(["**/*Test.java"]), 22 | deps = [ 23 | "//java/com/google/copybara/configgen", 24 | "//java/com/google/copybara/util", 25 | "//third_party:truth", 26 | ], 27 | ) 28 | -------------------------------------------------------------------------------- /java/com/google/copybara/profiler/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | licenses(["notice"]) 16 | 17 | package(default_visibility = ["//visibility:public"]) 18 | 19 | java_library( 20 | name = "profiler", 21 | srcs = glob(["**/*.java"]), 22 | deps = [ 23 | "//java/com/google/copybara/util/console", 24 | "//third_party:flogger", 25 | "//third_party:guava", 26 | "//third_party:jsr305", 27 | ], 28 | ) 29 | -------------------------------------------------------------------------------- /javatests/com/google/copybara/remotefile/extractutil/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//javatests/com/google/copybara:test.bzl", "all_tests") 16 | 17 | licenses(["notice"]) 18 | 19 | all_tests( 20 | name = "all_tests", 21 | tests = glob(["*.java"]), 22 | deps = [ 23 | "//java/com/google/copybara/remotefile/extractutil", 24 | "//java/com/google/copybara/util", 25 | "//third_party:truth", 26 | ], 27 | ) 28 | -------------------------------------------------------------------------------- /java/com/google/copybara/starlark/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | licenses(["notice"]) 16 | 17 | package(default_visibility = ["//visibility:public"]) 18 | 19 | JAVACOPTS = [ 20 | "-Xlint:unchecked", 21 | ] 22 | 23 | java_library( 24 | name = "starlark", 25 | srcs = glob(["**/*.java"]), 26 | javacopts = JAVACOPTS, 27 | deps = [ 28 | "//third_party:error_prone", 29 | "//third_party:starlark", 30 | ], 31 | ) 32 | -------------------------------------------------------------------------------- /javatests/com/google/copybara/util/console/testing/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//javatests/com/google/copybara:test.bzl", "all_tests") 16 | 17 | licenses(["notice"]) 18 | 19 | all_tests( 20 | name = "all_tests", 21 | tests = glob(["*.java"]), 22 | deps = [ 23 | "//java/com/google/copybara/util/console", 24 | "//java/com/google/copybara/util/console/testing", 25 | "//third_party:truth", 26 | ], 27 | ) 28 | -------------------------------------------------------------------------------- /javatests/com/google/copybara/hashing/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//javatests/com/google/copybara:test.bzl", "all_tests") 16 | 17 | licenses(["notice"]) 18 | 19 | all_tests( 20 | name = "all_tests", 21 | data = [ 22 | ], 23 | tests = glob(["**/*.java"]), 24 | deps = [ 25 | "//java/com/google/copybara/exception", 26 | "//java/com/google/copybara/testing", 27 | "//third_party:truth", 28 | ], 29 | ) 30 | -------------------------------------------------------------------------------- /java/com/google/copybara/git/RebaseConflictException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.git; 18 | 19 | import com.google.copybara.exception.ValidationException; 20 | 21 | /** Indicates that the rebase failed because of a conflict. */ 22 | public class RebaseConflictException extends ValidationException { 23 | 24 | RebaseConflictException(String message) { 25 | super(message); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /java/com/google/copybara/hg/testing/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | licenses(["notice"]) 16 | 17 | package(default_visibility = ["//visibility:public"]) 18 | 19 | java_library( 20 | name = "testing", 21 | testonly = 1, 22 | srcs = [ 23 | "HgTesting.java", 24 | ], 25 | javacopts = [ 26 | "-Xlint:unchecked", 27 | ], 28 | visibility = ["//visibility:public"], 29 | deps = ["//java/com/google/copybara/testing"], 30 | ) 31 | -------------------------------------------------------------------------------- /java/com/google/copybara/xml/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | licenses(["notice"]) 16 | 17 | package(default_visibility = ["//visibility:public"]) 18 | 19 | java_library( 20 | name = "xml", 21 | srcs = glob(["**/*.java"]), 22 | deps = [ 23 | "//java/com/google/copybara/config:base", 24 | "//java/com/google/copybara/doc:annotations", 25 | "//java/com/google/copybara/exception", 26 | "//third_party:starlark", 27 | ], 28 | ) 29 | -------------------------------------------------------------------------------- /java/com/google/copybara/exception/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | licenses(["notice"]) 16 | 17 | package(default_visibility = ["//visibility:public"]) 18 | 19 | JAVACOPTS = [ 20 | "-Xlint:unchecked", 21 | ] 22 | 23 | java_library( 24 | name = "exception", 25 | srcs = glob( 26 | ["**/*.java"], 27 | ), 28 | javacopts = JAVACOPTS, 29 | deps = [ 30 | "//third_party:error_prone", 31 | "//third_party:starlark", 32 | ], 33 | ) 34 | -------------------------------------------------------------------------------- /javatests/com/google/copybara/json/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//javatests/com/google/copybara:test.bzl", "all_tests") 16 | 17 | licenses(["notice"]) 18 | 19 | all_tests( 20 | name = "all_tests", 21 | tests = glob(["**/*Test.java"]), 22 | deps = [ 23 | "//java/com/google/copybara/json", 24 | "//third_party:google_http_client", 25 | "//third_party:google_http_client_test", 26 | "//third_party:truth", 27 | ], 28 | ) 29 | -------------------------------------------------------------------------------- /javatests/com/google/copybara/xml/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//javatests/com/google/copybara:test.bzl", "all_tests") 16 | 17 | licenses(["notice"]) 18 | 19 | all_tests( 20 | name = "all_tests", 21 | tests = ["XmlTest.java"], 22 | deps = [ 23 | "//java/com/google/copybara/exception", 24 | "//java/com/google/copybara/testing", 25 | "//java/com/google/copybara/util/console/testing", 26 | "//third_party:truth", 27 | ], 28 | ) 29 | -------------------------------------------------------------------------------- /java/com/google/copybara/exception/RepoException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.exception; 18 | 19 | /** 20 | * Exceptions that happen during repository manipulation. 21 | */ 22 | public class RepoException extends Exception { 23 | 24 | public RepoException(String message) { 25 | super(message); 26 | } 27 | 28 | public RepoException(String message, Throwable cause) { 29 | super(message, cause); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /java/com/google/copybara/onboard/core/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | licenses(["notice"]) 16 | 17 | package(default_visibility = ["//visibility:public"]) 18 | 19 | java_library( 20 | name = "core", 21 | srcs = glob(["**/*.java"]), 22 | deps = [ 23 | "//java/com/google/copybara/util", 24 | "//java/com/google/copybara/util/console", 25 | "//third_party:guava", 26 | "//third_party:jsr305", 27 | "//third_party:re2j", 28 | ], 29 | ) 30 | -------------------------------------------------------------------------------- /java/com/google/copybara/html/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Google LLC. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | licenses(["notice"]) 16 | 17 | package(default_visibility = ["//visibility:public"]) 18 | 19 | java_library( 20 | name = "html", 21 | srcs = glob(["**/*.java"]), 22 | deps = [ 23 | "//java/com/google/copybara/doc:annotations", 24 | "//java/com/google/copybara/exception", 25 | "//third_party:guava", 26 | "//third_party:jsoup", 27 | "//third_party:starlark", 28 | ], 29 | ) 30 | -------------------------------------------------------------------------------- /java/com/google/copybara/onboard/ConfigFieldPopulator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.onboard; 18 | 19 | import com.google.copybara.exception.ValidationException; 20 | import java.io.IOException; 21 | 22 | /** An object to populate Config Template fields in Copybara Assisted Onboard */ 23 | @FunctionalInterface 24 | public interface ConfigFieldPopulator { 25 | 26 | public T run() throws IOException, ValidationException; 27 | } 28 | -------------------------------------------------------------------------------- /java/com/google/copybara/git/InvalidRefspecException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.git; 18 | 19 | import com.google.copybara.exception.ValidationException; 20 | 21 | /** 22 | * Exception thrown when an invalid refspec is passed to Copybara via config, flags, etc. 23 | */ 24 | public class InvalidRefspecException extends ValidationException { 25 | 26 | InvalidRefspecException(String message) { 27 | super(message); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /java/com/google/copybara/testing/profiler/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | licenses(["notice"]) 16 | 17 | package(default_visibility = ["//visibility:public"]) 18 | 19 | java_library( 20 | name = "profiler", 21 | testonly = 1, 22 | srcs = glob(["**/*.java"]), 23 | javacopts = [ 24 | "-Xlint:unchecked", 25 | ], 26 | deps = [ 27 | "//java/com/google/copybara/profiler", 28 | "//third_party:guava", 29 | "//third_party:truth", 30 | ], 31 | ) 32 | -------------------------------------------------------------------------------- /java/com/google/copybara/util/console/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | package(default_visibility = ["//visibility:public"]) 16 | 17 | licenses(["notice"]) 18 | 19 | java_library( 20 | name = "console", 21 | srcs = glob(["**/*.java"]), 22 | deps = [ 23 | "//third_party:autovalue", 24 | "//third_party:error_prone", 25 | "//third_party:flogger", 26 | "//third_party:guava", 27 | "//third_party:jsr305", 28 | "//third_party:starlark", 29 | ], 30 | ) 31 | -------------------------------------------------------------------------------- /java/com/google/copybara/authoring/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | package(default_visibility = ["//visibility:public"]) 16 | 17 | licenses(["notice"]) 18 | 19 | java_library( 20 | name = "authoring", 21 | srcs = glob(["**/*.java"]), 22 | javacopts = [ 23 | "-Xlint:unchecked", 24 | ], 25 | deps = [ 26 | "//java/com/google/copybara/doc:annotations", 27 | "//third_party:guava", 28 | "//third_party:re2j", 29 | "//third_party:starlark", 30 | ], 31 | ) 32 | -------------------------------------------------------------------------------- /java/com/google/copybara/exception/CommandLineException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.exception; 18 | 19 | 20 | /** 21 | * An exception due to a command line error 22 | */ 23 | public class CommandLineException extends ValidationException { 24 | 25 | public CommandLineException(String message) { 26 | super(message); 27 | } 28 | 29 | public CommandLineException(String message, Throwable cause) { 30 | super(message, cause); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /java/com/google/copybara/git/github/api/AuthorAssociation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.git.github.api; 18 | 19 | /** 20 | * GitHub type of author for pull request, reviews, etc. 21 | * 22 | *

See https://developer.github.com/v4/reference/enum/commentauthorassociation/ 23 | */ 24 | public enum AuthorAssociation { 25 | CONTRIBUTOR, 26 | COLLABORATOR, 27 | MEMBER, 28 | OWNER, 29 | NONE, 30 | FIRST_TIMER, 31 | FIRST_TIME_CONTRIBUTOR, 32 | } 33 | -------------------------------------------------------------------------------- /javatests/com/google/copybara/util/console/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//javatests/com/google/copybara:test.bzl", "all_tests") 16 | 17 | licenses(["notice"]) 18 | 19 | all_tests( 20 | name = "all_tests", 21 | tests = glob(["*.java"]), 22 | deps = [ 23 | "//java/com/google/copybara/util/console", 24 | "//java/com/google/copybara/util/console/testing", 25 | "//third_party:jimfs", 26 | "//third_party:mockito", 27 | "//third_party:truth", 28 | ], 29 | ) 30 | -------------------------------------------------------------------------------- /java/com/google/copybara/effect/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | licenses(["notice"]) 16 | 17 | package(default_visibility = ["//visibility:public"]) 18 | 19 | java_library( 20 | name = "effect", 21 | srcs = glob(["**/*.java"]), 22 | deps = [ 23 | "//java/com/google/copybara/doc:annotations", # Used for doc generation 24 | "//java/com/google/copybara/revision", 25 | "//third_party:guava", 26 | "//third_party:jsr305", 27 | "//third_party:starlark", 28 | ], 29 | ) 30 | -------------------------------------------------------------------------------- /java/com/google/copybara/exception/VoidOperationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.exception; 18 | 19 | 20 | /** 21 | * An exception that indicates that an operation, as defined, does not do anything to the 22 | * repository. This usually indicates a problem with the configuration. 23 | */ 24 | public class VoidOperationException extends ValidationException { 25 | public VoidOperationException(String message) { 26 | super(message); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /javatests/com/google/copybara/re2/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//javatests/com/google/copybara:test.bzl", "all_tests") 16 | 17 | licenses(["notice"]) 18 | 19 | all_tests( 20 | name = "all_tests", 21 | tests = ["Re2Test.java"], 22 | deps = [ 23 | "//java/com/google/copybara/exception", 24 | "//java/com/google/copybara/testing", 25 | "//java/com/google/copybara/util/console/testing", 26 | "//third_party:starlark", 27 | "//third_party:truth", 28 | ], 29 | ) 30 | -------------------------------------------------------------------------------- /java/com/google/copybara/hashing/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | licenses(["notice"]) 16 | 17 | package(default_visibility = ["//visibility:public"]) 18 | 19 | java_library( 20 | name = "hashing", 21 | srcs = [ 22 | "HashingModule.java", 23 | ], 24 | deps = [ 25 | "//java/com/google/copybara:base", 26 | "//java/com/google/copybara/config:base", 27 | "//java/com/google/copybara/exception", 28 | "//third_party:guava", 29 | "//third_party:starlark", 30 | ], 31 | ) 32 | -------------------------------------------------------------------------------- /javatests/com/google/copybara/html/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Google LLC. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//javatests/com/google/copybara:test.bzl", "all_tests") 16 | 17 | licenses(["notice"]) 18 | 19 | all_tests( 20 | name = "all_tests", 21 | tests = ["HtmlTest.java"], 22 | deps = [ 23 | "//java/com/google/copybara/exception", 24 | "//java/com/google/copybara/html", 25 | "//java/com/google/copybara/testing", 26 | "//java/com/google/copybara/util/console/testing", 27 | "//third_party:truth", 28 | ], 29 | ) 30 | -------------------------------------------------------------------------------- /.bazelrc: -------------------------------------------------------------------------------- 1 | # Options applied to all Bazel invocations in the workspace. 2 | # Enforces UTF-8 encoding in bazel tests. 3 | test --test_env='LC_ALL=en_US.UTF-8' 4 | test --test_env='LANG=en_US.UTF-8' 5 | test --jvmopt='-Dsun.jnu.encoding=UTF-8' 6 | test --jvmopt='-Dfile.encoding=UTF-8' 7 | build --test_env='LC_ALL=en_US.UTF-8' 8 | build --jvmopt='-Dsun.jnu.encoding=UTF-8' 9 | build --jvmopt='-Dfile.encoding=UTF-8' 10 | build --test_env='LANG=en_US.UTF-8' 11 | test --test_env=PATH 12 | 13 | build --java_language_version=11 14 | test --java_language_version=11 15 | build --tool_java_language_version=11 16 | test --tool_java_language_version=11 17 | 18 | 19 | ################################################################################ 20 | # User bazel configuration 21 | ################################################################################ 22 | 23 | # Load from the local configuration file, if it exists. This needs to be the 24 | # *last* statement in the root configuration file, as the local configuration 25 | # file should be able to overwrite flags from the root configuration. 26 | try-import %workspace%/.bazelrc.user 27 | -------------------------------------------------------------------------------- /java/com/google/copybara/remotefile/HttpStreamFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.remotefile; 18 | 19 | import java.io.IOException; 20 | import java.io.InputStream; 21 | import java.net.URL; 22 | 23 | /** 24 | * Interface for opening a URL for downloading a file 25 | */ 26 | public interface HttpStreamFactory { 27 | 28 | /** 29 | * Open the referenced URL and return the stream to the contents. 30 | */ 31 | InputStream open(URL url) throws IOException; 32 | } 33 | -------------------------------------------------------------------------------- /java/com/google/copybara/onboard/core/CannotConvertException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.onboard.core; 18 | 19 | /** 20 | * Thrown by a Converter if it cannot convert a {@code String} to the corresponding type T. 21 | */ 22 | public class CannotConvertException extends Exception { 23 | 24 | public CannotConvertException(String message) { 25 | super(message); 26 | } 27 | public CannotConvertException(String message, Exception e) { 28 | super(message, e); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /javatests/com/google/copybara/checks/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//javatests/com/google/copybara:test.bzl", "all_tests") 16 | 17 | licenses(["notice"]) 18 | 19 | all_tests( 20 | name = "all_tests", 21 | tests = glob(["**/*Test.java"]), 22 | deps = [ 23 | "//java/com/google/copybara/checks", 24 | "//java/com/google/copybara/exception", 25 | "//java/com/google/copybara/util/console", 26 | "//java/com/google/copybara/util/console/testing", 27 | "//third_party:truth", 28 | ], 29 | ) 30 | -------------------------------------------------------------------------------- /.docker/copybara: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Handle environment variables for backwards compatibility 4 | if [ -n "${COPYBARA_SUBCOMMAND}" ] || [ -n "${COPYBARA_CONFIG}" ] || [ -n "${COPYBARA_WORKFLOW}" ] || [ -n "${COPYBARA_SOURCEREF}" ] || [ -n "${COPYBARA_OPTIONS}" ]; then 5 | echo "Detected \$COPYBARA_* environment variables, overwriting shell args" 6 | ARGS=() 7 | if [ -n "${COPYBARA_SUBCOMMAND}" ]; then 8 | ARGS+=("${COPYBARA_SUBCOMMAND}") 9 | else 10 | ARGS+=("migrate") 11 | fi 12 | if [ -n "${COPYBARA_CONFIG}" ]; then 13 | ARGS+=("${COPYBARA_CONFIG}") 14 | else 15 | ARGS+=("copy.bara.sky") 16 | fi 17 | if [ -n "${COPYBARA_WORKFLOW}" ]; then 18 | ARGS+=("${COPYBARA_WORKFLOW}") 19 | else 20 | ARGS+=("default") 21 | fi 22 | if [ -n "${COPYBARA_SOURCEREF}" ]; then 23 | ARGS+=("${COPYBARA_SOURCEREF}") 24 | fi 25 | if [ -n "${COPYBARA_OPTIONS}" ]; then 26 | ARGS+=(${COPYBARA_OPTIONS}) # no quotation marks to split them by space 27 | fi 28 | echo "Setting arguments to: \"${ARGS[@]}\"" 29 | set -- "${ARGS[@]}" 30 | fi 31 | 32 | exec java -jar /opt/copybara/copybara_deploy.jar "$@" 33 | -------------------------------------------------------------------------------- /java/com/google/copybara/exception/NotADestinationFileException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.exception; 18 | 19 | 20 | /** 21 | * An exception that indicates a file that was to be written to a destination is not actually 22 | * included in {@code destination_files}, indicating a bad configuration. 23 | */ 24 | public class NotADestinationFileException extends ValidationException { 25 | 26 | public NotADestinationFileException(String message) { 27 | super(message); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /java/com/google/copybara/revision/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | licenses(["notice"]) 16 | 17 | package(default_visibility = ["//visibility:public"]) 18 | 19 | java_library( 20 | name = "revision", 21 | srcs = glob(["**/*.java"]), 22 | deps = [ 23 | "//java/com/google/copybara/authoring", 24 | "//java/com/google/copybara/doc:annotations", 25 | "//java/com/google/copybara/exception", 26 | "//third_party:guava", 27 | "//third_party:jsr305", 28 | "//third_party:starlark", 29 | ], 30 | ) 31 | -------------------------------------------------------------------------------- /java/com/google/copybara/templatetoken/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | licenses(["notice"]) 16 | 17 | package(default_visibility = ["//visibility:public"]) 18 | 19 | java_library( 20 | name = "templatetoken", 21 | srcs = glob(["**/*.java"]), 22 | javacopts = [ 23 | "-Xlint:unchecked", 24 | ], 25 | deps = [ 26 | "//java/com/google/copybara/starlark", 27 | "//third_party:guava", 28 | "//third_party:jsr305", 29 | "//third_party:re2j", 30 | "//third_party:starlark", 31 | ], 32 | ) 33 | -------------------------------------------------------------------------------- /java/com/google/copybara/exception/CannotResolveLabel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.exception; 18 | 19 | /** 20 | * An exception thrown when a dependency expressed as a label in a content cannot be resolved. 21 | */ 22 | public class CannotResolveLabel extends ValidationException { 23 | 24 | public CannotResolveLabel(String message) { 25 | super(message); 26 | } 27 | 28 | public CannotResolveLabel(String message, Exception exception) { 29 | super(message, exception); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /java/com/google/copybara/exception/CannotResolveRevisionException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.exception; 18 | 19 | 20 | /** Indicates that a revision could not be resolved in a repository. */ 21 | public class CannotResolveRevisionException extends ValidationException { 22 | public CannotResolveRevisionException(String message) { 23 | super(message); 24 | } 25 | 26 | public CannotResolveRevisionException(String message, Throwable cause) { 27 | super(message, cause); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /java/com/google/copybara/onboard/core/CannotProvideException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.onboard.core; 18 | 19 | /** 20 | * Thrown when a {@code InputProvider} cannot provide a given set of {@code Input objects} 21 | */ 22 | public class CannotProvideException extends Exception { 23 | 24 | public CannotProvideException(String message) { 25 | super(message); 26 | } 27 | 28 | public CannotProvideException(String message, Throwable cause) { 29 | super(message, cause); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /java/com/google/copybara/checks/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | package(default_visibility = ["//visibility:public"]) 16 | 17 | licenses(["notice"]) 18 | 19 | java_library( 20 | name = "checks", 21 | srcs = glob(["**/*.java"]), 22 | javacopts = [ 23 | "-Xlint:unchecked", 24 | ], 25 | deps = [ 26 | "//java/com/google/copybara/exception", 27 | "//java/com/google/copybara/util/console", 28 | "//third_party:error_prone", 29 | "//third_party:guava", 30 | "//third_party:starlark", 31 | ], 32 | ) 33 | -------------------------------------------------------------------------------- /java/com/google/copybara/checks/CheckerException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.checks; 18 | 19 | import com.google.copybara.exception.ValidationException; 20 | 21 | /** 22 | * Indicates an exception running a {@link Checker}. 23 | */ 24 | public class CheckerException extends ValidationException { 25 | 26 | public CheckerException(String message, Throwable cause) { 27 | super(message, cause); 28 | } 29 | 30 | public CheckerException(String message) { 31 | super(message); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /java/com/google/copybara/credentials/Credential.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2023 Google LLC. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.copybara.credentials; 17 | 18 | /** Holder for a credential. */ 19 | public interface Credential { 20 | 21 | /** A safe value that describes the credential */ 22 | String printableValue(); 23 | 24 | /** Whether the creential is still believed to be valid */ 25 | boolean valid(); 26 | 27 | /** The raw secret, this should not be used outside of framework code. */ 28 | String provideSecret() throws CredentialRetrievalException; 29 | } 30 | -------------------------------------------------------------------------------- /java/com/google/copybara/git/github/api/testing/get_authenticated_user_response_testdata.json: -------------------------------------------------------------------------------- 1 | { 2 | "login": "googletestuser", 3 | "id": 123456, 4 | "avatar_url": "https://avatars2.githubusercontent.com/u/123456?v=4", 5 | "gravatar_id": "", 6 | "url": "https://api.github.com/users/googletestuser", 7 | "html_url": "https://github.com/googletestuser", 8 | "followers_url": "https://api.github.com/users/googletestuser/followers", 9 | "following_url": "https://api.github.com/users/googletestuser/following{/other_user}", 10 | "gists_url": "https://api.github.com/users/googletestuser/gists{/gist_id}", 11 | "starred_url": "https://api.github.com/users/googletestuser/starred{/owner}{/repo}", 12 | "subscriptions_url": "https://api.github.com/users/googletestuser/subscriptions", 13 | "organizations_url": "https://api.github.com/users/googletestuser/orgs", 14 | "repos_url": "https://api.github.com/users/googletestuser/repos", 15 | "events_url": "https://api.github.com/users/googletestuser/events{/privacy}", 16 | "received_events_url": "https://api.github.com/users/googletestuser/received_events", 17 | "type": "User", 18 | "site_admin": false 19 | } 20 | -------------------------------------------------------------------------------- /java/com/google/copybara/hg/testing/HgTesting.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.hg.testing; 18 | 19 | import com.google.copybara.testing.OptionsBuilder; 20 | 21 | /** 22 | * Testing utilities for Hg. 23 | */ 24 | public class HgTesting { 25 | 26 | private HgTesting() {} 27 | 28 | /** 29 | * Makes the Hg binary available with the given options. 30 | */ 31 | public static void enableBinary(OptionsBuilder options) { 32 | // TODO(jlliu): Implement in order to make OSS tests hermetic 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /java/com/google/copybara/http/multipart/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | package(default_visibility = ["//visibility:public"]) 16 | 17 | java_library( 18 | name = "multipart", 19 | srcs = glob(["**/*.java"]), 20 | deps = [ 21 | "//java/com/google/copybara/checks", 22 | "//java/com/google/copybara/http/endpoint", 23 | "//java/com/google/copybara/util/console", 24 | "//third_party:google_http_client", 25 | "//third_party:guava", 26 | "//third_party:jsr305", 27 | "//third_party:starlark", 28 | ], 29 | ) 30 | -------------------------------------------------------------------------------- /javatests/com/google/copybara/http/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Google LLC. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//javatests/com/google/copybara:test.bzl", "all_tests") 16 | 17 | licenses(["notice"]) 18 | 19 | all_tests( 20 | name = "all_tests", 21 | tests = glob(["*Test.java"]), 22 | deps = [ 23 | "//java/com/google/copybara/exception", 24 | "//java/com/google/copybara/http", 25 | "//java/com/google/copybara/http/testing", 26 | "//java/com/google/copybara/testing", 27 | "//third_party:google_http_client", 28 | "//third_party:truth", 29 | ], 30 | ) 31 | -------------------------------------------------------------------------------- /javatests/com/google/copybara/http/json/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Google LLC. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//javatests/com/google/copybara:test.bzl", "all_tests") 16 | 17 | licenses(["notice"]) 18 | 19 | all_tests( 20 | name = "all_tests", 21 | tests = glob(["*Test.java"]), 22 | deps = [ 23 | "//java/com/google/copybara/exception", 24 | "//java/com/google/copybara/http", 25 | "//java/com/google/copybara/http/testing", 26 | "//java/com/google/copybara/testing", 27 | "//third_party:google_http_client", 28 | "//third_party:truth", 29 | ], 30 | ) 31 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing guidelines 2 | 3 | ## How to become a contributor and submit your own code 4 | 5 | ### Contributor License Agreements 6 | 7 | We'd love to accept your patches! Before we can take them, we have to jump a couple of legal hurdles. 8 | 9 | Please fill out either the individual or corporate Contributor License Agreement (CLA). 10 | 11 | * If you are an individual writing original source code and you're sure you own the intellectual property, then you'll need to sign an [individual CLA](http://code.google.com/legal/individual-cla-v1.0.html). 12 | * If you work for a company that wants to allow you to contribute your work, then you'll need to sign a [corporate CLA](http://code.google.com/legal/corporate-cla-v1.0.html). 13 | 14 | Follow either of the two links above to access the appropriate CLA and instructions for how to sign and return it. Once we receive it, we'll be able to accept your pull requests. 15 | 16 | ***NOTE***: Only original source code from you and other people that have signed the CLA can be accepted into the main repository. 17 | 18 | ### Contributing code 19 | 20 | If you have improvements to Copybara, send us your pull requests! 21 | -------------------------------------------------------------------------------- /java/com/google/copybara/git/CannotIntegrateException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.git; 18 | 19 | import com.google.copybara.exception.ValidationException; 20 | 21 | /** 22 | * Thrown if git destination integrate failed for some reason 23 | */ 24 | public class CannotIntegrateException extends ValidationException { 25 | 26 | CannotIntegrateException(String message) { 27 | super(message); 28 | } 29 | 30 | CannotIntegrateException(String message, Throwable cause) { 31 | super(message, cause); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /java/com/google/copybara/remotefile/extractutil/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | package(default_visibility = ["//visibility:public"]) 16 | 17 | licenses(["notice"]) 18 | 19 | java_library( 20 | name = "extractutil", 21 | srcs = glob(["*.java"]), 22 | javacopts = [ 23 | "-Xlint:unchecked", 24 | ], 25 | deps = [ 26 | "//java/com/google/copybara/exception", 27 | "//java/com/google/copybara/util", 28 | "//third_party:apache_commons_compress", 29 | "//third_party:guava", 30 | "//third_party:jsr305", 31 | ], 32 | ) 33 | -------------------------------------------------------------------------------- /java/com/google/copybara/toml/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | licenses(["notice"]) 16 | 17 | package(default_visibility = ["//visibility:public"]) 18 | 19 | java_library( 20 | name = "toml", 21 | srcs = glob(["**/*.java"]), 22 | deps = [ 23 | "//java/com/google/copybara:starlark_date_time_module", 24 | "//java/com/google/copybara/doc:annotations", # Used for doc generation 25 | "//java/com/google/copybara/exception", 26 | "//third_party:guava", 27 | "//third_party:starlark", 28 | "//third_party:tomlj", 29 | ], 30 | ) 31 | -------------------------------------------------------------------------------- /javatests/com/google/copybara/python/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//javatests/com/google/copybara:test.bzl", "all_tests") 16 | 17 | licenses(["notice"]) 18 | 19 | all_tests( 20 | name = "python", 21 | data = [":testfiles"], 22 | env = {"DATA_DIR": "$(rlocationpath //javatests/com/google/copybara/python:testfiles)"}, 23 | tests = glob(["*.java"]), 24 | deps = [ 25 | "//java/com/google/copybara/exception", 26 | "//java/com/google/copybara/testing", 27 | "//third_party:starlark", 28 | "//third_party:truth", 29 | ], 30 | ) 31 | -------------------------------------------------------------------------------- /java/com/google/copybara/git/github/api/testing/user_permission_level_testdata.json: -------------------------------------------------------------------------------- 1 | { 2 | "permission": "admin", 3 | "user": { 4 | "login": "octocat", 5 | "id": 1, 6 | "node_id": "MDQ6VXNlcjE=", 7 | "avatar_url": "https://github.com/images/error/octocat_happy.gif", 8 | "gravatar_id": "", 9 | "url": "https://api.github.com/users/octocat", 10 | "html_url": "https://github.com/octocat", 11 | "followers_url": "https://api.github.com/users/octocat/followers", 12 | "following_url": "https://api.github.com/users/octocat/following{/other_user}", 13 | "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", 14 | "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", 15 | "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", 16 | "organizations_url": "https://api.github.com/users/octocat/orgs", 17 | "repos_url": "https://api.github.com/users/octocat/repos", 18 | "events_url": "https://api.github.com/users/octocat/events{/privacy}", 19 | "received_events_url": "https://api.github.com/users/octocat/received_events", 20 | "type": "User", 21 | "site_admin": false 22 | } 23 | } -------------------------------------------------------------------------------- /javatests/com/google/copybara/toml/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//javatests/com/google/copybara:test.bzl", "all_tests") 16 | 17 | licenses(["notice"]) 18 | 19 | all_tests( 20 | name = "all_tests", 21 | tests = ["TomlTest.java"], 22 | deps = [ 23 | "//java/com/google/copybara:starlark_date_time_module", 24 | "//java/com/google/copybara/exception", 25 | "//java/com/google/copybara/testing", 26 | "//java/com/google/copybara/util/console/testing", 27 | "//third_party:starlark", 28 | "//third_party:truth", 29 | ], 30 | ) 31 | -------------------------------------------------------------------------------- /java/com/google/copybara/doc/annotations/DocDefaults.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.doc.annotations; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * A collection of {@link DocDefault} for a @StarlarkMethod function. 26 | */ 27 | @Retention(RetentionPolicy.RUNTIME) 28 | @Target({ElementType.METHOD}) 29 | public @interface DocDefaults { 30 | 31 | DocDefault[] value(); 32 | } 33 | -------------------------------------------------------------------------------- /javatests/com/google/copybara/archive/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//javatests/com/google/copybara:test.bzl", "all_tests") 16 | 17 | licenses(["notice"]) 18 | 19 | all_tests( 20 | name = "all_tests", 21 | tests = glob(["*Test.java"]), 22 | deps = [ 23 | "//java/com/google/copybara:base", 24 | "//java/com/google/copybara/exception", 25 | "//java/com/google/copybara/testing", 26 | "//java/com/google/copybara/util/console", 27 | "//java/com/google/copybara/util/console/testing", 28 | "//third_party:truth", 29 | ], 30 | ) 31 | -------------------------------------------------------------------------------- /javatests/com/google/copybara/profiler/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//javatests/com/google/copybara:test.bzl", "all_tests") 16 | 17 | licenses(["notice"]) 18 | 19 | all_tests( 20 | name = "all_tests", 21 | tests = glob(["**/*Test.java"]), 22 | deps = [ 23 | "//java/com/google/copybara/profiler", 24 | "//java/com/google/copybara/testing/profiler", 25 | "//java/com/google/copybara/util/console", 26 | "//java/com/google/copybara/util/console/testing", 27 | "//third_party:guava_testlib", 28 | "//third_party:truth", 29 | ], 30 | ) 31 | -------------------------------------------------------------------------------- /third_party/bazel/main/java/com/google/copybara/shell/ExecFailedException.java: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Bazel Authors. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package com.google.copybara.shell; 16 | 17 | /** 18 | * Thrown when a command could not even be executed by the JVM -- 19 | * in particular, when {@link Runtime#exec(String[])} fails. 20 | */ 21 | public final class ExecFailedException extends CommandException { 22 | 23 | public ExecFailedException(Command command, final Throwable cause) { 24 | super(command, cause); 25 | } 26 | 27 | private static final long serialVersionUID = 2L; 28 | } 29 | -------------------------------------------------------------------------------- /java/com/google/copybara/doc/annotations/Examples.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.doc.annotations; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * A collection of examples for a Copybara element. 26 | */ 27 | @Retention(RetentionPolicy.RUNTIME) 28 | @Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD}) 29 | public @interface Examples { 30 | 31 | Example[] value(); 32 | } 33 | -------------------------------------------------------------------------------- /java/com/google/copybara/credentials/CredentialIssuingException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2023 Google LLC. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.copybara.credentials; 17 | 18 | import com.google.copybara.exception.ValidationException; 19 | 20 | /** 21 | * An Exception thrown if minting a credential fails. 22 | */ 23 | public class CredentialIssuingException extends ValidationException { 24 | 25 | public CredentialIssuingException(String message) { 26 | super(message); 27 | } 28 | 29 | public CredentialIssuingException(String message, Throwable cause) { 30 | super(message, cause); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /java/com/google/copybara/git/gerritapi/ReviewerInput.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.git.gerritapi; 18 | 19 | import com.google.api.client.util.Key; 20 | import com.google.api.client.util.Preconditions; 21 | 22 | /** see https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#reviewer-input 23 | * request json 24 | */ 25 | public class ReviewerInput { 26 | 27 | @Key private String reviewer; 28 | 29 | public ReviewerInput(String reviewer) { 30 | this.reviewer = Preconditions.checkNotNull(reviewer); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /java/com/google/copybara/util/console/testing/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | licenses(["notice"]) 16 | 17 | package(default_visibility = ["//visibility:public"]) 18 | 19 | java_library( 20 | name = "testing", 21 | testonly = 1, 22 | srcs = glob(["**/*.java"]), 23 | javacopts = [ 24 | "-Xlint:unchecked", 25 | ], 26 | visibility = [ 27 | "//visibility:public", 28 | ], 29 | deps = [ 30 | "//java/com/google/copybara/util/console", 31 | "//third_party:guava", 32 | "//third_party:jsr305", 33 | "//third_party:truth", 34 | ], 35 | ) 36 | -------------------------------------------------------------------------------- /java/com/google/copybara/ConfigLoaderProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara; 18 | 19 | import com.google.copybara.exception.ValidationException; 20 | import java.io.IOException; 21 | import javax.annotation.Nullable; 22 | 23 | /** A class that given a main config path (copy.bara.sky file) returns a ConfigLoader. */ 24 | public interface ConfigLoaderProvider { 25 | 26 | /** Create a new loader for {@code configPath} */ 27 | ConfigLoader newLoader(String configPath, @Nullable String sourceRef) 28 | throws ValidationException, IOException; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /java/com/google/copybara/compression/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | licenses(["notice"]) 16 | 17 | package(default_visibility = ["//visibility:public"]) 18 | 19 | java_library( 20 | name = "compression", 21 | srcs = [ 22 | "CompressionModule.java", 23 | ], 24 | deps = [ 25 | "//java/com/google/copybara:base", 26 | "//java/com/google/copybara/config:base", 27 | "//java/com/google/copybara/exception", 28 | "//java/com/google/copybara/remotefile/extractutil", 29 | "//java/com/google/copybara/util", 30 | "//third_party:starlark", 31 | ], 32 | ) 33 | -------------------------------------------------------------------------------- /java/com/google/copybara/credentials/CredentialRetrievalException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2023 Google LLC. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.copybara.credentials; 17 | 18 | import com.google.copybara.exception.ValidationException; 19 | 20 | /** 21 | * An Exception thrown if retrieving a credential fails. 22 | */ 23 | public class CredentialRetrievalException extends ValidationException { 24 | 25 | public CredentialRetrievalException(String message) { 26 | super(message); 27 | } 28 | 29 | public CredentialRetrievalException(String message, Throwable cause) { 30 | super(message, cause); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /java/com/google/copybara/exception/EmptyChangeException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.exception; 18 | 19 | /** 20 | * An exception thrown by destinations when they detect that there is no change to submit. Usually 21 | * this means that the change was already applied. 22 | */ 23 | public class EmptyChangeException extends ValidationException { 24 | 25 | public EmptyChangeException(String message) { 26 | super(message); 27 | } 28 | 29 | public EmptyChangeException(Throwable cause, String message) { 30 | super(message, cause); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /javatests/com/google/copybara/transform/debug/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//javatests/com/google/copybara:test.bzl", "all_tests") 16 | 17 | licenses(["notice"]) 18 | 19 | all_tests( 20 | name = "all_tests", 21 | tags = ["local"], 22 | tests = ["TransformDebugTest.java"], 23 | deps = [ 24 | "//java/com/google/copybara:copybara_lib", 25 | "//java/com/google/copybara/exception", 26 | "//java/com/google/copybara/testing", 27 | "//java/com/google/copybara/util/console", 28 | "//third_party:mockito", 29 | "//third_party:truth", 30 | ], 31 | ) 32 | -------------------------------------------------------------------------------- /java/com/google/copybara/approval/NoneApprovedProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.approval; 18 | 19 | 20 | import com.google.common.collect.ImmutableList; 21 | import com.google.copybara.util.console.Console; 22 | 23 | /** An approval provider that return all the changes as not approved */ 24 | public class NoneApprovedProvider implements ApprovalsProvider { 25 | 26 | @Override 27 | public ApprovalsResult computeApprovals( 28 | ImmutableList changes, Console console) { 29 | return new ApprovalsResult(changes); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /java/com/google/copybara/credentials/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Google LLC. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | package(default_visibility = ["//visibility:public"]) 16 | 17 | licenses(["notice"]) 18 | 19 | java_library( 20 | name = "credentials", 21 | srcs = glob(["*.java"]), 22 | deps = [ 23 | "//java/com/google/copybara:options", 24 | "//java/com/google/copybara/exception", 25 | "//java/com/google/copybara/util/console", 26 | "//third_party:autovalue", 27 | "//third_party:guava", 28 | "//third_party:jsr305", 29 | "//third_party:starlark", 30 | "//third_party:tomlj", 31 | ], 32 | ) 33 | -------------------------------------------------------------------------------- /java/com/google/copybara/profiler/Listener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.profiler; 18 | 19 | /** 20 | * A listener that, when registered in a {@link Profiler}, will be notified everytime 21 | * a task is started/finished. 22 | */ 23 | public interface Listener { 24 | 25 | /** 26 | * A notification about a task that has started. 27 | */ 28 | void taskStarted(Task task); 29 | 30 | /** 31 | * A notification about a task finish. It is guaranteed that {@link Task#isFinished()} 32 | * will return true. 33 | */ 34 | void taskFinished(Task task); 35 | } 36 | -------------------------------------------------------------------------------- /javatests/com/google/copybara/git/github/util/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//javatests/com/google/copybara:test.bzl", "all_tests") 16 | 17 | # Used for extending the tests internally. Not a public API. 18 | package(default_visibility = ["//visibility:public"]) 19 | 20 | licenses(["notice"]) 21 | 22 | all_tests( 23 | name = "all_tests", 24 | tests = [ 25 | "GitHubHostTest.java", 26 | "GitHubUtilTest.java", 27 | ], 28 | deps = [ 29 | "//java/com/google/copybara/exception", 30 | "//java/com/google/copybara/git/github:util", 31 | "//third_party:truth", 32 | ], 33 | ) 34 | -------------------------------------------------------------------------------- /javatests/com/google/copybara/http/auth/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//javatests/com/google/copybara:test.bzl", "all_tests") 16 | 17 | licenses(["notice"]) 18 | 19 | all_tests( 20 | name = "all_tests", 21 | tests = glob(["*Test.java"]), 22 | deps = [ 23 | "//java/com/google/copybara/credentials", 24 | "//java/com/google/copybara/exception", 25 | "//java/com/google/copybara/http", 26 | "//java/com/google/copybara/http/testing", 27 | "//java/com/google/copybara/testing", 28 | "//third_party:google_http_client", 29 | "//third_party:truth", 30 | ], 31 | ) 32 | -------------------------------------------------------------------------------- /java/com/google/copybara/git/github/api/PaginatedPayload.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2023 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.git.github.api; 18 | 19 | import javax.annotation.Nullable; 20 | 21 | /** JSON response contains a nested payload */ 22 | public interface PaginatedPayload { 23 | 24 | /** 25 | * Return the list of paginated entities 26 | */ 27 | PaginatedList getPayload(); 28 | 29 | /** 30 | * Add prev/next info from HTTP headers, returning a new instance with the data filled. 31 | */ 32 | PaginatedPayload annotatePayload(String apiPrefix, @Nullable String linkHeader); 33 | } 34 | -------------------------------------------------------------------------------- /java/com/google/copybara/git/testing/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | licenses(["notice"]) 16 | 17 | package(default_visibility = ["//visibility:public"]) 18 | 19 | java_library( 20 | name = "testing", 21 | testonly = 1, 22 | srcs = glob(["**/*.java"]), 23 | javacopts = [ 24 | "-Xlint:unchecked", 25 | ], 26 | visibility = ["//visibility:public"], 27 | deps = [ 28 | "//java/com/google/copybara/exception", 29 | "//java/com/google/copybara/git:core", 30 | "//java/com/google/copybara/testing", 31 | "//third_party:guava", 32 | "//third_party:truth", 33 | ], 34 | ) 35 | -------------------------------------------------------------------------------- /java/com/google/copybara/git/github/api/testing/lsremote_testdata.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "ref": "refs/heads/master", 4 | "url": "https://api.github.com/repos/copybara-test/copybara/git/refs/heads/master", 5 | "object": { 6 | "sha": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 7 | "type": "commit", 8 | "url": "https://api.github.com/repos/copybara-test/copybara-test/git/commits/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" 9 | } 10 | }, 11 | { 12 | "ref": "refs/pull/1/head", 13 | "url": "https://api.github.com/repos/copybara-test/copybara/git/refs/pull/1/head", 14 | "object": { 15 | "sha": "1234567890123456789012345678901234567890", 16 | "type": "commit", 17 | "url": "https://api.github.com/repos/copybara-test/copybara-test/git/commits/1234567890123456789012345678901234567890" 18 | } 19 | }, 20 | { 21 | "ref": "refs/pull/1/merge", 22 | "url": "https://api.github.com/repos/copybara-test/copybara/git/refs/pull/1/merge", 23 | "object": { 24 | "sha": "abcdefabcdefabcdefabcdefabcdefabcdefabcd", 25 | "type": "commit", 26 | "url": "https://api.github.com/repos/copybara-test/copybara/git/commits/abcdefabcdefabcdefabcdefabcdefabcdefabcd" 27 | } 28 | } 29 | ] -------------------------------------------------------------------------------- /java/com/google/copybara/version/VersionResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.version; 18 | 19 | import com.google.copybara.exception.ValidationException; 20 | import com.google.copybara.revision.Revision; 21 | import java.util.Optional; 22 | import java.util.function.Function; 23 | import net.starlark.java.eval.StarlarkValue; 24 | 25 | /** Takes a ref and resolves it to the repository */ 26 | public interface VersionResolver extends StarlarkValue { 27 | Revision resolve(String ref, Function> assemblyStrategy) 28 | throws ValidationException; 29 | } 30 | -------------------------------------------------------------------------------- /third_party/bazel/main/java/com/google/copybara/shell/ProcessKillable.java: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Bazel Authors. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package com.google.copybara.shell; 16 | 17 | /** 18 | * {@link Killable} implementation which simply wraps a 19 | * {@link Process} instance. 20 | */ 21 | final class ProcessKillable implements Killable { 22 | 23 | private final Process process; 24 | 25 | ProcessKillable(final Process process) { 26 | this.process = process; 27 | } 28 | 29 | /** 30 | * Calls {@link Process#destroy()}. 31 | */ 32 | @Override 33 | public void kill() { 34 | process.destroy(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /java/com/google/copybara/SkylarkContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara; 18 | 19 | import com.google.copybara.exception.ValidationException; 20 | import net.starlark.java.eval.Dict; 21 | 22 | /** 23 | * A context object that can be enhanced with Skylark information. 24 | */ 25 | public interface SkylarkContext { 26 | 27 | /** Create a copy instance with Skylark function parameters. */ 28 | T withParams(Dict params); 29 | 30 | /** Performs tasks after Starlark code finishes. */ 31 | void onFinish(Object result, SkylarkContext context) throws ValidationException; 32 | } 33 | -------------------------------------------------------------------------------- /java/com/google/copybara/config/OptionsAwareModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.config; 18 | 19 | import com.google.copybara.Options; 20 | import net.starlark.java.annot.StarlarkBuiltin; 21 | 22 | /** 23 | * A {@link StarlarkBuiltin} that implements this interface will be initialized with the options. 24 | * 25 | *

This method will be invoked just after registering the namespace objects in Skylark. 26 | */ 27 | public interface OptionsAwareModule { 28 | 29 | /** 30 | * Set the options for the current Copybara run. 31 | */ 32 | void setOptions(Options options); 33 | } 34 | -------------------------------------------------------------------------------- /java/com/google/copybara/credentials/CredentialOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2023 Google LLC. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.copybara.credentials; 17 | 18 | import com.google.copybara.Option; 19 | import java.nio.file.Path; 20 | import javax.annotation.Nullable; 21 | 22 | /** 23 | * Flags related to credentials 24 | */ 25 | public class CredentialOptions implements Option { 26 | 27 | /* 28 | TODO(b/270712326) enable this flag 29 | @Parameter( 30 | names = "--credential-file", 31 | description = "location of toml file for reading credentials" 32 | ) 33 | */ 34 | @Nullable public Path credentialFile = null; 35 | } 36 | -------------------------------------------------------------------------------- /java/com/google/copybara/approval/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | licenses(["notice"]) 16 | 17 | package(default_visibility = ["//visibility:public"]) 18 | 19 | JAVACOPTS = [ 20 | "-Xlint:unchecked", 21 | ] 22 | 23 | java_library( 24 | name = "approval", 25 | srcs = glob(["**/*.java"]), 26 | javacopts = JAVACOPTS, 27 | deps = [ 28 | "//java/com/google/copybara/exception", 29 | "//java/com/google/copybara/revision", 30 | "//java/com/google/copybara/util/console", 31 | "//third_party:error_prone", 32 | "//third_party:google_http_client", 33 | "//third_party:guava", 34 | ], 35 | ) 36 | -------------------------------------------------------------------------------- /java/com/google/copybara/exception/AccessValidationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.exception; 18 | 19 | /** 20 | * A special case of {@link ValidationException} when the error is likely to be a user error related 21 | * to access to the repo (access denied, not found, etc.) 22 | */ 23 | public class AccessValidationException extends ValidationException { 24 | 25 | public AccessValidationException(String message) { 26 | super(message); 27 | 28 | } 29 | 30 | public AccessValidationException(String message, Throwable cause) { 31 | super(message, cause); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /third_party/bazel/main/java/com/google/copybara/shell/Killable.java: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Bazel Authors. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package com.google.copybara.shell; 16 | 17 | /** 18 | * Implementations encapsulate a running process that can be killed. 19 | * In particular, here, it is used to wrap up a {@link Process} object 20 | * and expose it to a {@link KillableObserver}. It is wrapped in this way 21 | * so that the actual {@link Process} object can't be altered by 22 | * a {@link KillableObserver}. 23 | */ 24 | public interface Killable { 25 | 26 | /** 27 | * Kill this killable instance. 28 | */ 29 | void kill(); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /java/com/google/copybara/onboard/core/Converter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.onboard.core; 18 | 19 | /** 20 | * A {@code Converter} is a function that allows converting a String to the corresponding T type. 21 | * It should be used only in the context of {@code Data} objects. 22 | */ 23 | public interface Converter { 24 | 25 | /** 26 | * Convert {@code value} to {@code T}. 27 | * 28 | * @throws CannotConvertException if the conversion is not possible (e.g. wrong input). 29 | */ 30 | T convert(String value, InputProviderResolver resolver) throws CannotConvertException; 31 | } 32 | -------------------------------------------------------------------------------- /java/com/google/copybara/authoring/InvalidAuthorException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.authoring; 18 | 19 | /** 20 | * Indicates that the author does not conform to the expected format. 21 | * 22 | *

This exception does not extend other exceptions {@code ValidationException} or 23 | * {@code RepoException} because a bad parsed author could come from a configuration or a repo, and 24 | * it's wrapped into the proper one by the caller. 25 | */ 26 | public class InvalidAuthorException extends Exception { 27 | 28 | InvalidAuthorException(String message) { 29 | super(message); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /java/com/google/copybara/doc/annotations/Library.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.doc.annotations; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * An annotation for a class that causes its StarlarkMethod-annotated methods to be predeclared in 26 | * the environment (by SkylarkParser) and added to the documentation (by MarkdownGenerator). 27 | */ 28 | @Retention(RetentionPolicy.RUNTIME) 29 | @Target({ElementType.TYPE}) 30 | public @interface Library {} 31 | -------------------------------------------------------------------------------- /java/com/google/copybara/jcommander/SemicolonSeparatedListSplitter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2023 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.jcommander; 18 | 19 | import com.beust.jcommander.converters.IParameterSplitter; 20 | import com.google.common.collect.ImmutableList; 21 | import java.util.List; 22 | 23 | /** 24 | * Converts a semicolon separated string to a list. E.g. --my-option "foo;bar;baz" to [foo, bar, 25 | * baz] 26 | */ 27 | public class SemicolonSeparatedListSplitter implements IParameterSplitter { 28 | @Override 29 | public List split(String value) { 30 | return ImmutableList.copyOf(value.split(";")); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /java/com/google/copybara/archive/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | package(default_visibility = ["//visibility:public"]) 16 | 17 | licenses(["notice"]) 18 | 19 | java_library( 20 | name = "archive", 21 | srcs = glob(["**/*.java"]), 22 | deps = [ 23 | "//java/com/google/copybara:base", 24 | "//java/com/google/copybara/config:base", 25 | "//java/com/google/copybara/doc:annotations", 26 | "//java/com/google/copybara/exception", 27 | "//java/com/google/copybara/remotefile/extractutil", 28 | "//java/com/google/copybara/util", 29 | "//third_party:guava", 30 | "//third_party:starlark", 31 | ], 32 | ) 33 | -------------------------------------------------------------------------------- /java/com/google/copybara/git/gerritapi/DeleteReviewerInput.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.git.gerritapi; 18 | 19 | import com.google.api.client.util.Key; 20 | import javax.annotation.Nullable; 21 | 22 | /** 23 | * See https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#delete-reviewer-input 24 | * 25 | *

NotifyInfo (notify_details) not included for now 26 | */ 27 | public class DeleteReviewerInput { 28 | 29 | @Key String notify; 30 | 31 | public DeleteReviewerInput(@Nullable NotifyType notify) { 32 | this.notify = notify == null ? null : notify.toString(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /javatests/com/google/copybara/credentials/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Google LLC. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//javatests/com/google/copybara:test.bzl", "all_tests") 16 | 17 | licenses(["notice"]) 18 | 19 | all_tests( 20 | name = "all_tests", 21 | tests = glob(["*Test.java"]), 22 | deps = [ 23 | "//java/com/google/copybara/credentials", 24 | "//java/com/google/copybara/exception", 25 | "//java/com/google/copybara/http", 26 | "//java/com/google/copybara/http/testing", 27 | "//java/com/google/copybara/testing", 28 | "//third_party:google_http_client", 29 | "//third_party:starlark", 30 | "//third_party:truth", 31 | ], 32 | ) 33 | -------------------------------------------------------------------------------- /javatests/com/google/copybara/onboard/core/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//javatests/com/google/copybara:test.bzl", "all_tests") 16 | 17 | licenses(["notice"]) 18 | 19 | all_tests( 20 | name = "all_tests", 21 | tests = glob( 22 | ["**/*Test.java"], 23 | ), 24 | deps = [ 25 | "//java/com/google/copybara/onboard", 26 | "//java/com/google/copybara/onboard/core", 27 | "//java/com/google/copybara/testing", 28 | "//java/com/google/copybara/util", 29 | "//java/com/google/copybara/util/console", 30 | "//java/com/google/copybara/util/console/testing", 31 | "//third_party:truth", 32 | ], 33 | ) 34 | -------------------------------------------------------------------------------- /java/com/google/copybara/util/console/EnhancedPredicate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.util.console; 18 | 19 | import com.google.auto.value.AutoValue; 20 | import com.google.common.base.Predicate; 21 | 22 | /** Enhanced Predicate object for use with Copybara console objects */ 23 | @AutoValue 24 | public abstract class EnhancedPredicate { 25 | 26 | public static EnhancedPredicate create(Predicate predicate, String errorMsg) { 27 | return new AutoValue_EnhancedPredicate(predicate, errorMsg); 28 | } 29 | 30 | public abstract Predicate predicate(); 31 | 32 | public abstract String errorMsg(); 33 | } 34 | -------------------------------------------------------------------------------- /java/com/google/copybara/git/github/api/CommentBody.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.git.github.api; 18 | 19 | import com.google.api.client.util.Key; 20 | import java.util.Optional; 21 | import javax.annotation.Nullable; 22 | 23 | /** 24 | * Request type for https://docs.github.com/en/rest/reference/issues#create-an-issue-comment 25 | */ 26 | public class CommentBody { 27 | @Key @Nullable String body; 28 | 29 | public CommentBody(String body) { 30 | this.body = body; 31 | } 32 | 33 | public CommentBody() { 34 | } 35 | 36 | public Optional getBody() { 37 | return Optional.ofNullable(body); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /copybara/integration/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | licenses(["notice"]) 16 | 17 | sh_test( 18 | name = "reference_doc_test", 19 | srcs = ["reference_doc_test.sh"], 20 | data = [ 21 | "//docs:reference.md", 22 | "//java/com/google/copybara:reference.md", 23 | "//third_party/bazel/bashunit", 24 | ], 25 | visibility = ["//visibility:public"], 26 | ) 27 | 28 | sh_test( 29 | name = "tool_test", 30 | srcs = ["tool_test.sh"], 31 | data = [ 32 | "//java/com/google/copybara", 33 | "//third_party/bazel/bashunit", 34 | ], 35 | shard_count = 30, 36 | tags = ["local"], 37 | visibility = ["//visibility:public"], 38 | ) 39 | -------------------------------------------------------------------------------- /java/com/google/copybara/credentials/CredentialIssuer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2023 Google LLC. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.copybara.credentials; 17 | 18 | import com.google.common.collect.ImmutableSetMultimap; 19 | import net.starlark.java.eval.StarlarkValue; 20 | 21 | /** 22 | * An object able to mint credentials. The issuer should handle caching etc. 23 | */ 24 | public interface CredentialIssuer extends StarlarkValue { 25 | 26 | /** 27 | * Issue a Credential to be used by an endpoint 28 | */ 29 | Credential issue() throws CredentialIssuingException; 30 | 31 | /** 32 | * Metadata describing this issuer. 33 | */ 34 | ImmutableSetMultimap describe(); 35 | } 36 | -------------------------------------------------------------------------------- /java/com/google/copybara/exception/NonReversibleValidationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.exception; 18 | 19 | import net.starlark.java.eval.EvalException; 20 | 21 | /** 22 | * Exception thrown when a {@link com.google.copybara.Transformation} is not reversible 23 | * but the configuration asked for the reverse. 24 | */ 25 | public class NonReversibleValidationException extends EvalException { 26 | 27 | public NonReversibleValidationException(String message) { 28 | super(message); 29 | } 30 | 31 | public NonReversibleValidationException(String message, Throwable cause) { 32 | super(message, cause); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /java/com/google/copybara/testing/DummyTrigger.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.testing; 18 | 19 | import com.google.copybara.Endpoint; 20 | import com.google.copybara.Trigger; 21 | import net.starlark.java.annot.StarlarkBuiltin; 22 | 23 | /** 24 | * A dummy trigger for feedback mechanism. 25 | * 26 | *

Extends {@link DummyEndpoint} just for convenience for the tests. 27 | */ 28 | @StarlarkBuiltin(name = "dummy_trigger", doc = "A dummy trigger for feedback mechanism") 29 | public class DummyTrigger extends DummyEndpoint implements Trigger { 30 | 31 | @Override 32 | public Endpoint getEndpoint() { 33 | return this; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /java/com/google/copybara/http/HttpOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2023 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.http; 18 | 19 | import com.google.api.client.http.HttpTransport; 20 | import com.google.api.client.http.javanet.NetHttpTransport; 21 | import com.google.copybara.Option; 22 | import com.google.copybara.exception.ValidationException; 23 | 24 | /** Options relating to the http endpoint. */ 25 | public class HttpOptions implements Option { 26 | HttpTransport transport; 27 | 28 | public HttpTransport getTransport() throws ValidationException { 29 | if (transport == null) { 30 | transport = new NetHttpTransport(); 31 | } 32 | return transport; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /java/com/google/copybara/jcommander/GreaterThanZeroValidator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.jcommander; 18 | 19 | import com.beust.jcommander.IParameterValidator; 20 | import com.beust.jcommander.ParameterException; 21 | 22 | /** 23 | * Check if a parameter is greater than zero. 24 | */ 25 | public class GreaterThanZeroValidator implements IParameterValidator { 26 | 27 | public void validate(String name, String value) throws ParameterException { 28 | if (Integer.parseInt(value) < 1) { 29 | throw new ParameterException( 30 | String.format("Parameter %s should be greater than zero (found %s)", name, value)); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /java/com/google/copybara/monitor/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | package(default_visibility = ["//visibility:public"]) 16 | 17 | licenses(["notice"]) 18 | 19 | java_library( 20 | name = "monitor", 21 | srcs = glob(["**/*.java"]), 22 | javacopts = [ 23 | "-Xlint:unchecked", 24 | ], 25 | deps = [ 26 | "//java/com/google/copybara:base", 27 | "//java/com/google/copybara/effect", 28 | "//java/com/google/copybara/profiler", 29 | "//java/com/google/copybara/revision", 30 | "//java/com/google/copybara/util", 31 | "//java/com/google/copybara/util/console", 32 | "//third_party:guava", 33 | "//third_party:jsr305", 34 | ], 35 | ) 36 | -------------------------------------------------------------------------------- /java/com/google/copybara/remotefile/RemoteArchiveVersionSelector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.copybara.remotefile; 17 | 18 | import com.beust.jcommander.internal.Nullable; 19 | import com.google.copybara.exception.ValidationException; 20 | 21 | /** 22 | * An interface for version selecting logic to use with a RemoteArchiveOrigin object. Individual 23 | * implementations should be exposed as @StarlarkBuiltin objects 24 | */ 25 | public interface RemoteArchiveVersionSelector { 26 | 27 | public RemoteArchiveVersion constructUrl( 28 | String baseUrl, @Nullable String requestedRef, RemoteFileOptions remoteFileOptions) 29 | throws ValidationException; 30 | } 31 | -------------------------------------------------------------------------------- /java/com/google/copybara/util/console/AnsiColor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.util.console; 18 | 19 | /** 20 | * Colors to print messages in the console 21 | */ 22 | public enum AnsiColor { 23 | RESET("\u001B[0m"), 24 | BLACK("\u001B[30m"), 25 | RED("\u001B[31m"), 26 | GREEN("\u001B[32m"), 27 | YELLOW("\u001B[33m"), 28 | BLUE("\u001B[34m"), 29 | PURPLE("\u001B[35m"), 30 | CYAN("\u001B[36m"), 31 | WHITE("\u001B[37m"); 32 | 33 | private final String color; 34 | 35 | AnsiColor(String ansiColor) { 36 | this.color = ansiColor; 37 | } 38 | 39 | String write(String text) { 40 | return color + text + RESET.color; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /java/com/google/copybara/git/gerritapi/SubmitInput.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.git.gerritapi; 18 | 19 | import com.google.api.client.util.Key; 20 | import javax.annotation.Nullable; 21 | 22 | /** see https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#submit-change 23 | * request json 24 | *

NotifyInfo (notify_details) not included for now 25 | *

on_behalf_of not included for now until we have a use case. 26 | */ 27 | public class SubmitInput { 28 | 29 | @Key String notify; 30 | 31 | public SubmitInput(@Nullable NotifyType notify) { 32 | this.notify = notify == null ? null : notify.toString(); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /cloudbuild_setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | # Build script for Google Cloud Build 4 | 5 | function log() { 6 | d=$(date +'%Y-%m-%d %H:%M:%S') 7 | echo $d" "$1 8 | } 9 | 10 | log "Setting up Copybara test env" 11 | 12 | log "Fetching dependencies" 13 | log "Running apt-get update --fix-missing" 14 | 15 | apt-get update --fix-missing 16 | apt-get install -y locales 17 | apt-get install -y mercurial 18 | apt-get install -y lsb-release 19 | apt-get install -y software-properties-common 20 | 21 | add-apt-repository ppa:git-core/ppa -y 22 | apt install git -y 23 | 24 | apt-get install -y quilt 25 | 26 | log "Extracting Bazel" 27 | # Only because first time it extracts the installation 28 | bazel version 29 | 30 | echo "-----------------------------------" 31 | echo "Versions:" 32 | lsb_release -a 33 | hg --version | grep "(version" | sed 's/.*[(]version \([^ ]*\)[)].*/Mercurial: \1/' 34 | git --version | sed 's/git version/Git:/' 35 | bazel version | grep "Build label" | sed 's/Build label:/Bazel:/' 36 | java -version 37 | echo "Quilt:" 38 | quilt --version 39 | echo "-----------------------------------" 40 | 41 | log "Setting Locale" 42 | export LANGUAGE=en_US.UTF-8 43 | export LANG=en_US.UTF-8 44 | export LC_ALL=en_US.UTF-8 45 | locale-gen en_US.UTF-8 46 | update-locale LANG=en_US.UTF-8 47 | 48 | log "Setup Complete" 49 | -------------------------------------------------------------------------------- /java/com/google/copybara/git/gerritapi/IncludeResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.git.gerritapi; 18 | 19 | /** 20 | * Fields to include in the response {@link ChangeInfo}. 21 | */ 22 | public enum IncludeResult { 23 | LABELS, 24 | DETAILED_LABELS, 25 | CURRENT_REVISION, 26 | ALL_REVISIONS, 27 | DOWNLOAD_COMMANDS, 28 | CURRENT_COMMIT, 29 | ALL_COMMITS, 30 | CURRENT_FILES, 31 | ALL_FILES, 32 | DETAILED_ACCOUNTS, 33 | REVIEWER_UPDATES, 34 | MESSAGES, 35 | CURRENT_ACTIONS, 36 | CHANGE_ACTIONS, 37 | REVIEWED, 38 | SUBMITTABLE, 39 | WEB_LINKS, 40 | CHECK, 41 | COMMIT_FOOTERS, 42 | PUSH_CERTIFICATES, 43 | SUBMIT_REQUIREMENTS 44 | } 45 | -------------------------------------------------------------------------------- /java/com/google/copybara/remotefile/RemoteArchiveVersion.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.copybara.remotefile; 17 | 18 | import javax.annotation.Nullable; 19 | 20 | /** A class to represent Version for RemoteArchive Endpoints */ 21 | public final class RemoteArchiveVersion { 22 | 23 | private final String fullUrl; 24 | private final String version; 25 | 26 | public RemoteArchiveVersion(String fullUrl, String version) { 27 | this.version = version; 28 | this.fullUrl = fullUrl; 29 | } 30 | 31 | public String getFullUrl() { 32 | return this.fullUrl; 33 | } 34 | 35 | @Nullable 36 | public String getVersion() { 37 | return this.version; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /java/com/google/copybara/version/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | licenses(["notice"]) 16 | 17 | package(default_visibility = ["//visibility:public"]) 18 | 19 | JAVACOPTS = [ 20 | "-Xlint:unchecked", 21 | ] 22 | 23 | java_library( 24 | name = "version", 25 | srcs = glob(["**/*.java"]), 26 | javacopts = JAVACOPTS, 27 | deps = [ 28 | "//java/com/google/copybara/exception", 29 | "//java/com/google/copybara/revision", 30 | "//java/com/google/copybara/templatetoken", 31 | "//java/com/google/copybara/util/console", 32 | "//third_party:guava", 33 | "//third_party:jsr305", 34 | "//third_party:re2j", 35 | "//third_party:starlark", 36 | ], 37 | ) 38 | -------------------------------------------------------------------------------- /java/com/google/copybara/git/gerritapi/DeleteVoteInput.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.git.gerritapi; 18 | 19 | 20 | import com.google.api.client.util.Key; 21 | import javax.annotation.Nullable; 22 | 23 | /** see https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#delete-vote-input 24 | * request json 25 | *

NotifyInfo (notify_details) not included for now 26 | *

label not included for now since it matches the label in the URL. 27 | */ 28 | public class DeleteVoteInput { 29 | 30 | @Key String notify; 31 | 32 | public DeleteVoteInput(@Nullable NotifyType notify) { 33 | this.notify = notify == null ? null : notify.toString(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /java/com/google/copybara/transform/debug/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | package(default_visibility = ["//visibility:public"]) 16 | 17 | licenses(["notice"]) 18 | 19 | java_library( 20 | name = "debug", 21 | srcs = glob(["**/*.java"]), 22 | javacopts = [ 23 | "-Xlint:unchecked", 24 | ], 25 | deps = [ 26 | "//java/com/google/copybara:base", 27 | "//java/com/google/copybara:general_options", 28 | "//java/com/google/copybara/exception", 29 | "//java/com/google/copybara/util", 30 | "//java/com/google/copybara/util/console", 31 | "//third_party:guava", 32 | "//third_party:jcommander", 33 | "//third_party:jsr305", 34 | "//third_party:re2j", 35 | ], 36 | ) 37 | -------------------------------------------------------------------------------- /java/com/google/copybara/util/RepositoryUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.util; 18 | 19 | import static com.google.copybara.exception.ValidationException.checkCondition; 20 | 21 | import com.google.copybara.exception.ValidationException; 22 | 23 | /** 24 | * Utilities for Repositories. 25 | */ 26 | public class RepositoryUtil { 27 | 28 | /** 29 | * Verify that a repo URL is not plain HTTP 30 | */ 31 | public static String validateNotHttp(String url) throws ValidationException { 32 | checkCondition(!url.startsWith("http://"), 33 | "URL '%s' is not valid - should be using https.", url); 34 | return url; 35 | } 36 | 37 | private RepositoryUtil() { 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /javatests/com/google/copybara/monitor/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//javatests/com/google/copybara:test.bzl", "all_tests") 16 | 17 | licenses(["notice"]) 18 | 19 | all_tests( 20 | name = "all_tests", 21 | tests = glob(["*Test.java"]), 22 | deps = [ 23 | "//java/com/google/copybara:base", 24 | "//java/com/google/copybara/authoring", 25 | "//java/com/google/copybara/effect", 26 | "//java/com/google/copybara/monitor", 27 | "//java/com/google/copybara/revision", 28 | "//java/com/google/copybara/testing", 29 | "//java/com/google/copybara/util", 30 | "//java/com/google/copybara/util/console", 31 | "//java/com/google/copybara/util/console/testing", 32 | ], 33 | ) 34 | -------------------------------------------------------------------------------- /javatests/com/google/copybara/buildozer/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//javatests/com/google/copybara:test.bzl", "all_tests") 16 | 17 | licenses(["notice"]) 18 | 19 | all_tests( 20 | name = "all_tests", 21 | tests = glob(["*Test.java"]), 22 | deps = [ 23 | "//java/com/google/copybara:base", 24 | "//java/com/google/copybara/buildozer", 25 | "//java/com/google/copybara/buildozer/testing", 26 | "//java/com/google/copybara/exception", 27 | "//java/com/google/copybara/testing", 28 | "//java/com/google/copybara/transform", 29 | "//java/com/google/copybara/util/console", 30 | "//java/com/google/copybara/util/console/testing", 31 | "//third_party:truth", 32 | ], 33 | ) 34 | -------------------------------------------------------------------------------- /java/com/google/copybara/transform/ReversibleFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.transform; 18 | 19 | import com.google.copybara.exception.NonReversibleValidationException; 20 | import java.util.function.Function; 21 | import net.starlark.java.annot.StarlarkBuiltin; 22 | import net.starlark.java.eval.StarlarkValue; 23 | 24 | @StarlarkBuiltin( 25 | name = "mapping_function", 26 | doc = "A function that given an object can map to another object") 27 | public interface ReversibleFunction extends Function, StarlarkValue { 28 | 29 | /** 30 | * Create a reverse of the function 31 | */ 32 | ReversibleFunction reverseMapping() throws NonReversibleValidationException; 33 | } 34 | -------------------------------------------------------------------------------- /java/com/google/copybara/doc/annotations/DocSignaturePrefix.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.doc.annotations; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Adds a custom prefix to the signature example and reference in the generated Markdown 26 | */ 27 | @Retention(RetentionPolicy.RUNTIME) 28 | @Target({ElementType.TYPE}) 29 | public @interface DocSignaturePrefix { 30 | 31 | /** 32 | * When generating documentation use varPrefix + "." + method/field for generating the docs. 33 | * For example "ctx.origin" 34 | */ 35 | String value(); 36 | } 37 | -------------------------------------------------------------------------------- /java/com/google/copybara/git/EventTrigger.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.git; 18 | 19 | import com.google.auto.value.AutoValue; 20 | import com.google.common.collect.ImmutableSet; 21 | import com.google.copybara.git.github.api.GitHubEventType; 22 | 23 | /** 24 | * A simple pair to express GitHub Events with arbitrary subtypes (Status, CheckRun) 25 | */ 26 | @AutoValue 27 | public abstract class EventTrigger { 28 | public abstract GitHubEventType type(); 29 | 30 | public abstract ImmutableSet subtypes(); 31 | 32 | 33 | public static EventTrigger create(GitHubEventType type, Iterable subtypes) { 34 | return new AutoValue_EventTrigger(type, ImmutableSet.copyOf(subtypes)); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /java/com/google/copybara/http/endpoint/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | package(default_visibility = ["//visibility:public"]) 16 | 17 | java_library( 18 | name = "endpoint", 19 | srcs = glob(["**/*.java"]), 20 | deps = [ 21 | "//java/com/google/copybara:base", 22 | "//java/com/google/copybara/checks", 23 | "//java/com/google/copybara/config:base", 24 | "//java/com/google/copybara/credentials", 25 | "//java/com/google/copybara/exception", 26 | "//java/com/google/copybara/http/auth", 27 | "//java/com/google/copybara/util/console", 28 | "//third_party:google_http_client", 29 | "//third_party:guava", 30 | "//third_party:jsr305", 31 | "//third_party:starlark", 32 | ], 33 | ) 34 | -------------------------------------------------------------------------------- /java/com/google/copybara/jcommander/MapConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.copybara.jcommander; 17 | 18 | import com.beust.jcommander.IStringConverter; 19 | import com.google.common.base.Splitter; 20 | import com.google.common.collect.ImmutableMap; 21 | 22 | /** 23 | * Convert a String in the form of foo:value1,bar:value2 into an ImmutableMap of Strings. 24 | */ 25 | public class MapConverter implements IStringConverter> { 26 | 27 | @Override 28 | public ImmutableMap convert(String s) { 29 | return ImmutableMap 30 | .copyOf(Splitter.on(',') 31 | .omitEmptyStrings().trimResults().withKeyValueSeparator(':') 32 | .split(s)); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /java/com/google/copybara/CopybaraCmd.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara; 18 | 19 | import com.google.copybara.exception.RepoException; 20 | import com.google.copybara.exception.ValidationException; 21 | import com.google.copybara.util.ExitCode; 22 | import java.io.IOException; 23 | 24 | /** 25 | * A Copybara command like 'info' 'migrate', etc. 26 | */ 27 | public interface CopybaraCmd { 28 | 29 | /** 30 | * Run the command 31 | * @param commandEnv Command environment: Params, workdir, etc. 32 | * @return Result exit code 33 | */ 34 | ExitCode run(CommandEnv commandEnv) throws ValidationException, IOException, RepoException; 35 | 36 | /** 37 | * Command name 38 | */ 39 | String name(); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /java/com/google/copybara/http/endpoint/HttpEndpointBody.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2023 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.copybara.http.endpoint; 17 | 18 | import com.google.api.client.http.HttpContent; 19 | import com.google.copybara.checks.Checker; 20 | import com.google.copybara.checks.CheckerException; 21 | import com.google.copybara.util.console.Console; 22 | import java.io.IOException; 23 | 24 | /** An object containing the content portion of an http request */ 25 | public interface HttpEndpointBody { 26 | HttpContent getContent() throws IOException; 27 | 28 | default void checkContent(Checker checker, Console console) throws CheckerException, IOException { 29 | throw new CheckerException("checker not implemented for this content type"); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /java/com/google/copybara/git/GerritEventTrigger.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.git; 18 | 19 | import com.google.auto.value.AutoValue; 20 | import com.google.common.collect.ImmutableSet; 21 | import com.google.copybara.git.gerritapi.GerritEventType; 22 | 23 | /** 24 | * A simple pair to express Gerrit Events with arbitrary subtypes (Labels) 25 | */ 26 | @AutoValue 27 | public abstract class GerritEventTrigger { 28 | public abstract GerritEventType type(); 29 | 30 | public abstract ImmutableSet subtypes(); 31 | 32 | 33 | public static GerritEventTrigger create(GerritEventType type, Iterable subtypes) { 34 | return new AutoValue_GerritEventTrigger(type, ImmutableSet.copyOf(subtypes)); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /repositories.go.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") 16 | load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") 17 | load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository") 18 | 19 | def copybara_go_repositories(): 20 | go_rules_dependencies() 21 | 22 | go_register_toolchains(version = "1.19.5") 23 | 24 | gazelle_dependencies() 25 | 26 | # LICENSE: The Apache Software License, Version 2.0 27 | maybe( 28 | go_repository, 29 | name = "skylark_syntax", 30 | importpath = "go.starlark.net", 31 | sum = "h1:Qoe+9POtDT51UBQ8XEnS9QKeHDQzEl2QRh3eok9R4aw=", 32 | version = "v0.0.0-20200203144150-6677ee5c7211", 33 | ) 34 | -------------------------------------------------------------------------------- /java/com/google/copybara/git/gerritapi/RestoreInput.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.git.gerritapi; 18 | 19 | import com.google.api.client.util.Key; 20 | import javax.annotation.Nullable; 21 | 22 | /** 23 | * See https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#restore-input 24 | */ 25 | public class RestoreInput { 26 | 27 | @Key String message; 28 | 29 | private RestoreInput(@Nullable String message) { 30 | this.message = message; 31 | } 32 | 33 | public static RestoreInput create(@Nullable String message) { 34 | return new RestoreInput(message); 35 | } 36 | 37 | public static RestoreInput createWithoutComment() { 38 | return new RestoreInput(/*message=*/null); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /java/com/google/copybara/util/SettableSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.util; 18 | 19 | import com.google.common.base.Preconditions; 20 | import java.util.function.Supplier; 21 | 22 | /** 23 | * A {@link Supplier} that allows to defer setting the value after passing it as a parameter. 24 | */ 25 | public class SettableSupplier implements Supplier { 26 | 27 | private T value; 28 | 29 | public void set(T value) { 30 | Preconditions.checkState(this.value == null, "Value already set to: %s", this.value); 31 | this.value = Preconditions.checkNotNull(value); 32 | } 33 | 34 | @Override 35 | public T get() { 36 | return Preconditions.checkNotNull(value, "Value is still not set!"); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /java/com/google/copybara/Trigger.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara; 18 | 19 | import com.google.common.collect.ImmutableSetMultimap; 20 | import net.starlark.java.annot.StarlarkBuiltin; 21 | import net.starlark.java.eval.Printer; 22 | import net.starlark.java.eval.StarlarkValue; 23 | 24 | /** Starter of feedback migration executions. */ 25 | @StarlarkBuiltin( 26 | name = "trigger", 27 | doc = "Starter of feedback migration executions.", 28 | documented = false) 29 | public interface Trigger extends StarlarkValue { 30 | 31 | Endpoint getEndpoint(); 32 | 33 | @Override 34 | default void repr(Printer printer) { 35 | printer.append(toString()); 36 | } 37 | 38 | ImmutableSetMultimap describe(); 39 | } 40 | -------------------------------------------------------------------------------- /java/com/google/copybara/git/github/api/Label.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.git.github.api; 18 | 19 | import com.google.api.client.util.Key; 20 | import com.google.common.base.MoreObjects; 21 | 22 | /** 23 | * Represents a GitHub issue Label, e.g. https://developer.github.com/v3/issues/labels/#response-6 24 | */ 25 | public class Label { 26 | 27 | @Key private long id; 28 | @Key private String name; 29 | 30 | public long getId() { 31 | return id; 32 | } 33 | 34 | public String getName() { 35 | return name; 36 | } 37 | 38 | @Override 39 | public String toString() { 40 | return MoreObjects.toStringHelper(this) 41 | .add("id", id) 42 | .add("name", name) 43 | .toString(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /javatests/com/google/copybara/http/endpoint/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//javatests/com/google/copybara:test.bzl", "all_tests") 16 | 17 | licenses(["notice"]) 18 | 19 | all_tests( 20 | name = "all_tests", 21 | tests = glob(["*Test.java"]), 22 | deps = [ 23 | "//java/com/google/copybara/checks", 24 | "//java/com/google/copybara/config:base", 25 | "//java/com/google/copybara/exception", 26 | "//java/com/google/copybara/http", 27 | "//java/com/google/copybara/http/endpoint", 28 | "//java/com/google/copybara/http/testing", 29 | "//java/com/google/copybara/testing", 30 | "//third_party:google_http_client", 31 | "//third_party:jimfs", 32 | "//third_party:starlark", 33 | "//third_party:truth", 34 | ], 35 | ) 36 | -------------------------------------------------------------------------------- /java/com/google/copybara/format/BuildifierOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.format; 18 | 19 | import com.beust.jcommander.Parameter; 20 | import com.beust.jcommander.Parameters; 21 | import com.google.copybara.Option; 22 | 23 | /** 24 | * Specifies how Buildifier is executed. 25 | */ 26 | @Parameters(separators = "=") 27 | public class BuildifierOptions implements Option { 28 | @Parameter(names = "--buildifier-bin", 29 | description = "Binary to use for buildifier (Default is /usr/bin/buildifier)", 30 | hidden = true) 31 | public String buildifierBin = "/usr/bin/buildifier"; 32 | 33 | @Parameter(names = "--buildifier-batch-size", 34 | description = "Process files in batches this size") 35 | public int batchSize = 200; 36 | } 37 | -------------------------------------------------------------------------------- /java/com/google/copybara/starlark/StarlarkUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.starlark; 18 | 19 | import com.google.errorprone.annotations.FormatMethod; 20 | import com.google.errorprone.annotations.FormatString; 21 | import net.starlark.java.eval.EvalException; 22 | import net.starlark.java.eval.Starlark; 23 | 24 | /** Utilities for dealing with Starlark language. */ 25 | public final class StarlarkUtil { 26 | 27 | /** Checks a condition or throw {@link EvalException}. */ 28 | @FormatMethod 29 | public static void check(boolean condition, @FormatString String format, Object... args) 30 | throws EvalException { 31 | if (!condition) { 32 | throw Starlark.errorf(format, args); 33 | } 34 | } 35 | 36 | private StarlarkUtil() {} 37 | } 38 | -------------------------------------------------------------------------------- /java/com/google/copybara/git/github/api/AddAssignees.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2023 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.git.github.api; 18 | 19 | import com.google.api.client.json.GenericJson; 20 | import com.google.api.client.util.Key; 21 | import java.util.List; 22 | 23 | /** An object that represents the list of github users to assign to a pull request or issue */ 24 | public class AddAssignees extends GenericJson { 25 | 26 | @Key private List assignees; 27 | 28 | public List getAssignees() { 29 | return assignees; 30 | } 31 | 32 | public void setAssignees(List assignees) { 33 | this.assignees = assignees; 34 | } 35 | 36 | public AddAssignees(List assignees) { 37 | this.assignees = assignees; 38 | } 39 | 40 | public AddAssignees() {} 41 | } 42 | -------------------------------------------------------------------------------- /javatests/com/google/copybara/http/multipart/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//javatests/com/google/copybara:test.bzl", "all_tests") 16 | 17 | licenses(["notice"]) 18 | 19 | all_tests( 20 | name = "all_tests", 21 | tests = glob(["*Test.java"]), 22 | deps = [ 23 | "//java/com/google/copybara/checks", 24 | "//java/com/google/copybara/exception", 25 | "//java/com/google/copybara/http", 26 | "//java/com/google/copybara/http/endpoint", 27 | "//java/com/google/copybara/http/multipart", 28 | "//java/com/google/copybara/http/testing", 29 | "//java/com/google/copybara/testing", 30 | "//third_party:google_http_client", 31 | "//third_party:google_http_client_test", 32 | "//third_party:starlark", 33 | "//third_party:truth", 34 | ], 35 | ) 36 | -------------------------------------------------------------------------------- /javatests/com/google/copybara/version/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//javatests/com/google/copybara:test.bzl", "all_tests") 16 | 17 | licenses(["notice"]) 18 | 19 | all_tests( 20 | name = "all_tests", 21 | tests = [ 22 | "LatestVersionSelectorTest.java", 23 | "OrderedVersionSelectorTest.java", 24 | "RequestedExactMatchSelectorTest.java", 25 | "RequestedVersionSelectorTest.java", 26 | ], 27 | deps = [ 28 | "//java/com/google/copybara/exception", 29 | "//java/com/google/copybara/templatetoken", 30 | "//java/com/google/copybara/testing", 31 | "//java/com/google/copybara/util/console", 32 | "//java/com/google/copybara/util/console/testing", 33 | "//java/com/google/copybara/version", 34 | "//third_party:truth", 35 | ], 36 | ) 37 | -------------------------------------------------------------------------------- /java/com/google/copybara/http/HttpTrigger.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2023 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.http; 18 | 19 | import com.google.common.base.Preconditions; 20 | import com.google.common.collect.ImmutableSetMultimap; 21 | import com.google.copybara.Endpoint; 22 | import com.google.copybara.Trigger; 23 | 24 | /** HttpTrigger helps working with http origins. */ 25 | public class HttpTrigger implements Trigger { 26 | 27 | private final Endpoint endpoint; 28 | 29 | public HttpTrigger(Endpoint endpoint) { 30 | this.endpoint = Preconditions.checkNotNull(endpoint); 31 | } 32 | 33 | @Override 34 | public Endpoint getEndpoint() { 35 | return endpoint; 36 | } 37 | 38 | @Override 39 | public ImmutableSetMultimap describe() { 40 | return endpoint.describe(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /java/com/google/copybara/buildozer/testing/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | package(default_visibility = ["//visibility:public"]) 16 | 17 | licenses(["notice"]) 18 | 19 | genrule( 20 | name = "normalised_buildozer", 21 | testonly = 1, 22 | srcs = ["@buildtools//buildozer"], 23 | outs = ["buildozer"], 24 | cmd = "cp $(SRCS) $@", 25 | ) 26 | 27 | genrule( 28 | name = "normalised_buildifier", 29 | testonly = 1, 30 | srcs = ["@buildtools//buildifier"], 31 | outs = ["buildifier"], 32 | cmd = "cp $(SRCS) $@", 33 | ) 34 | 35 | java_library( 36 | name = "testing", 37 | testonly = 1, 38 | srcs = glob(["*.java"]), 39 | data = [ 40 | ":normalised_buildifier", 41 | ":normalised_buildozer", 42 | ], 43 | deps = [ 44 | "//java/com/google/copybara/testing", 45 | ], 46 | ) 47 | -------------------------------------------------------------------------------- /java/com/google/copybara/doc/annotations/DocDefault.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.doc.annotations; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Repeatable; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * Annotation for documenting fields for a @Param or return types 27 | * 28 | * TODO(malcon): Rename this to DocParam 29 | */ 30 | @Retention(RetentionPolicy.RUNTIME) 31 | @Target({ElementType.METHOD, ElementType.TYPE_USE}) 32 | @Repeatable(DocDefaults.class) 33 | public @interface DocDefault { 34 | String field(); 35 | // TODO(malcon): Rename to defaultValue 36 | String value() default ""; 37 | String[] allowedTypes() default {}; 38 | } 39 | -------------------------------------------------------------------------------- /java/com/google/copybara/git/github/api/AddLabels.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.git.github.api; 18 | 19 | import static com.google.common.base.Preconditions.checkNotNull; 20 | 21 | import com.google.api.client.util.Key; 22 | import com.google.common.collect.ImmutableList; 23 | import java.util.List; 24 | 25 | /** 26 | * Request type for adding a label to an issue 27 | * https://developer.github.com/v3/issues/labels/#add-labels-to-an-issue 28 | */ 29 | public class AddLabels { 30 | @Key List labels; 31 | 32 | public AddLabels(List labels) { 33 | this.labels = checkNotNull(ImmutableList.copyOf(labels)); 34 | } 35 | 36 | public AddLabels() { } 37 | 38 | public ImmutableList getLabels() { 39 | return ImmutableList.copyOf(labels); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /java/com/google/copybara/git/github/api/testing/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | licenses(["notice"]) 16 | 17 | package(default_visibility = ["//visibility:public"]) 18 | 19 | java_library( 20 | name = "abstract_gitapi_test", 21 | testonly = 1, 22 | srcs = [ 23 | "AbstractGitHubApiTest.java", 24 | "AbstractGitHubGraphQLApiTest.java", 25 | ], 26 | data = glob(["*_testdata.json"]), 27 | deps = [ 28 | "//java/com/google/copybara/exception", 29 | "//java/com/google/copybara/git/github:api", 30 | "//java/com/google/copybara/profiler", 31 | "//java/com/google/copybara/testing/git", 32 | "//third_party:guava", 33 | "//third_party:junit", 34 | "//third_party:mockito", 35 | "//third_party:starlark", 36 | "//third_party:truth", 37 | ], 38 | ) 39 | -------------------------------------------------------------------------------- /java/com/google/copybara/version/RequestedVersionSelector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.version; 18 | 19 | import com.google.copybara.exception.RepoException; 20 | import com.google.copybara.exception.ValidationException; 21 | import com.google.copybara.util.console.Console; 22 | import java.util.Optional; 23 | import javax.annotation.Nullable; 24 | 25 | /** 26 | * Given a requested version, it returns it as the selected version. None otherwise. 27 | */ 28 | public class RequestedVersionSelector implements VersionSelector { 29 | 30 | @Override 31 | public Optional select(VersionList versionList, @Nullable String requestedRef, 32 | Console console) 33 | throws ValidationException, RepoException { 34 | return Optional.ofNullable(requestedRef); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /java/com/google/copybara/onboard/ConfigTemplate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.copybara.onboard; 18 | 19 | import com.google.common.collect.ImmutableSet; 20 | 21 | /** A template object for use in Copybara's assisted onboarding. */ 22 | public interface ConfigTemplate { 23 | 24 | /** Locations for parameters */ 25 | enum Location { 26 | NAMED, 27 | KEYWORD, 28 | } 29 | 30 | /** Type of parameter */ 31 | enum FieldClass { 32 | STRING, 33 | INT, 34 | STARLARK 35 | } 36 | 37 | ImmutableSet getRequiredFields(); 38 | 39 | ImmutableSet getOptionalFields(); 40 | 41 | boolean validate(String configInProgress); 42 | 43 | String getTemplateString(); 44 | 45 | String name(); 46 | } 47 | --------------------------------------------------------------------------------