blob: 28ce7268532b6ad318856e0e5f4277fdddb512c0 [file] [log] [blame]
Copybara botca5ce642024-11-08 17:38:08 +01001load("test_repos_config", "test_origin_url", "test_destination_url")
2
3def export_workflow(name, description, mode, authoring_value, is_test):
4 if not is_test:
5 origin_url = "https://gerrit.avm99963.com/a/private/dotfiles"
6 destination_url = "https://gerrit.avm99963.com/a/dotfiles-external"
7 else:
8 origin_url = test_origin_url
9 destination_url = test_destination_url
10
Adrià Vilanova Martínezeafa1f82024-11-09 14:05:18 +010011 allPathsExceptCopybara = glob(
12 ["**"],
13 exclude = [".copybara/**"],
14 )
15
Copybara botca5ce642024-11-08 17:38:08 +010016 core.workflow(
17 name = name,
18 description = description,
19 origin = git.origin(
20 url = origin_url,
21 ref = "HEAD",
22 submodules = "NO",
23 ),
24 destination = git.destination(
25 url = destination_url,
26 push = "main",
27 ),
28 mode = mode,
29
30 origin_files = glob(
31 ["**"],
32 exclude = [
33 # Internal README
34 "README.md",
35
36 # Internal (dummy) license
37 "LICENSE",
38
39 # SSH configuration (it only includes the configuration for some
40 # hosts I connect to, which I don't want to be public).
41 "private_dot_ssh/**",
42
43 # .gitreview file only used for the private/dotfiles repo for the
44 # `git review` tool (https://docs.opendev.org/opendev/git-review/).
45 ".gitreview",
46 ],
47 ),
48
49 authoring = authoring_value,
50
51 transformations = [
52 core.rename('README.public.md', 'README.md'),
53 core.rename('LICENSE.public', 'LICENSE'),
54 core.replace(
55 before="private/dotfiles",
56 after="dotfiles-external",
Adrià Vilanova Martínezeafa1f82024-11-09 14:05:18 +010057 paths = allPathsExceptCopybara,
Copybara botca5ce642024-11-08 17:38:08 +010058 ),
Adrià Vilanova Martínez43e27cd2024-11-09 14:12:24 +010059 core.transform(
60 transformations = [
61 core.replace(
62 before = "${internalCode}",
63 after = "",
64 multiline = True,
65 regex_groups = {
66 "internalCode": "(?m)^.*BEGIN-INTERNAL[\\w\\W]*?END-INTERNAL.*$\\n",
67 },
68 paths = allPathsExceptCopybara,
69 ),
70 ],
71 reversal = [],
72 # TODO: Remove this once some code uses this transformation.
73 noop_behavior = 'IGNORE_NOOP',
Copybara botca5ce642024-11-08 17:38:08 +010074 ),
75 metadata.remove_label('Change-Id'),
76 ],
77 )
78
79export_workflow(
80 name = "firstExport",
81 description = "Moves code from the private repo (the SoT) to the public one. NOTE: This must only be used for the first migration.",
82 mode = "SQUASH",
83 authoring_value = authoring.overwrite("Copybara bot <copybara-bot@avm99963.com>"),
84 is_test = False,
85)
86
87export_workflow(
88 name = "exportCommits",
89 description = "Moves code from the private repo (the SoT) to the public one.",
90 mode = "ITERATIVE",
91 authoring_value = authoring.pass_thru("Copybara bot <copybara-bot@avm99963.com>"),
92 is_test = False,
93)
94
95# Local tests workflows
96export_workflow(
97 name = "firstExportTest",
98 description = "Test locally the first migration from the private repo to the public one. See README.md for more details.",
99 mode = "SQUASH",
100 authoring_value = authoring.overwrite("Copybara bot <copybara-bot@avm99963.com>"),
101 is_test = True,
102)
103
104export_workflow(
105 name = "exportCommitsTest",
106 description = "Test locally the migration from the private repo to the public one. See README.md for more details.",
107 mode = "ITERATIVE",
108 authoring_value = authoring.pass_thru("Copybara bot <copybara-bot@avm99963.com>"),
109 is_test = True,
110)
111
112# vim: set ft=bzl: