-
Notifications
You must be signed in to change notification settings - Fork 5.6k
/
Copy pathcopy.bara.sky
62 lines (59 loc) · 2.82 KB
/
copy.bara.sky
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# This configuration is for migrating code from one Git repository to another using Copybara.
# It selectively copies content, excluding specific paths and preserving authorship.
# To test locally
# sourceUrl = "/path/to/source"
# destinationUrl = "/path/to/dest"
sourceUrl = "https://github.com/10gen/mongo.git"
destinationUrl = "https://github.com/mongodb/mongo.git"
core.workflow(
name = "default",
origin = git.origin(
url = sourceUrl,
ref = "master",
),
destination = git.destination(
url = destinationUrl,
fetch = "master",
push = "master",
),
# Change path to the folder you want to publish publicly
origin_files = glob(["**"], exclude = ["src/mongo/db/modules/**"]),
authoring = authoring.pass_thru("MongoDB <[email protected]>"),
mode = "ITERATIVE",
transformations = [
# The transformation rules below will remove the commit message's body, while preserving
# any trailer lines that have acceptable keys (Co-authored-by, etc). The first line of
# the commit message (ie. the commit's subject/summary line) is also always retained.
#
# Achieving this requires a 4 step process.
#
# STEP 1: Non-initial lines (ie. those which appear after a newline char) that start with
# an acceptable trailer key are preserved, but any other lines have their content removed
# (leaving a blank line).
#
# This works because the first .* (inside capture group 1) only matches if the line starts
# with a trailer key. If it doesn't, then the line is fully consumed by the second .*
# (which is outside the capture group, and therefore $1 is empty).
metadata.scrubber(
"\n((?:Co-authored-by|Signed-off-by|Reviewed-by): .*)?.*",
replacement = "\n$1",
),
#
# STEP 2: Remove blank lines, ie. sequences of newlines get condensed down to one newline.
metadata.scrubber("\n+", replacement = "\n"),
#
# STEP 3: Remove any trailing newline.
metadata.scrubber("\n$", replacement = ""),
#
# STEP 4: If there are trailer lines (ie. if the first line has a newline followed by more
# text), then add an extra blank line after the first line, ie. to separate the commit's
# trailers from the subject line.
#
# The first capture group (^.*?\n) is the first line (non-greedily consuming chars until a
# newline), while the second capture group ((\n|.)*) is the rest of the message (greedily
# consume all chars, including newlines).
# If there are no trailers, then there will only be a single line of text, with no newline
# chars, and so the pattern will fail to match.
metadata.scrubber("(^.*?\n)((?:\n|.)*)", replacement = "$1\n$2"),
],
)