blob: 1b049de54ca3101675f026d73736ffa71f514a70 [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 ),
59 core.replace(
60 before = "${internalCode}",
61 after = "",
62 multiline = True,
63 regex_groups = {
Adrià Vilanova Martínezeafa1f82024-11-09 14:05:18 +010064 "internalCode": "(?m)^.*BEGIN-INTERNAL[\\w\\W]*?END-INTERNAL.*$\\n",
Copybara botca5ce642024-11-08 17:38:08 +010065 },
Adrià Vilanova Martínezeafa1f82024-11-09 14:05:18 +010066 paths = allPathsExceptCopybara,
Copybara botca5ce642024-11-08 17:38:08 +010067 ),
68 metadata.remove_label('Change-Id'),
69 ],
70 )
71
72export_workflow(
73 name = "firstExport",
74 description = "Moves code from the private repo (the SoT) to the public one. NOTE: This must only be used for the first migration.",
75 mode = "SQUASH",
76 authoring_value = authoring.overwrite("Copybara bot <copybara-bot@avm99963.com>"),
77 is_test = False,
78)
79
80export_workflow(
81 name = "exportCommits",
82 description = "Moves code from the private repo (the SoT) to the public one.",
83 mode = "ITERATIVE",
84 authoring_value = authoring.pass_thru("Copybara bot <copybara-bot@avm99963.com>"),
85 is_test = False,
86)
87
88# Local tests workflows
89export_workflow(
90 name = "firstExportTest",
91 description = "Test locally the first migration from the private repo to the public one. See README.md for more details.",
92 mode = "SQUASH",
93 authoring_value = authoring.overwrite("Copybara bot <copybara-bot@avm99963.com>"),
94 is_test = True,
95)
96
97export_workflow(
98 name = "exportCommitsTest",
99 description = "Test locally the migration from the private repo to the public one. See README.md for more details.",
100 mode = "ITERATIVE",
101 authoring_value = authoring.pass_thru("Copybara bot <copybara-bot@avm99963.com>"),
102 is_test = True,
103)
104
105# vim: set ft=bzl: