Debugging
Debugging Copybara
Section titled “Debugging Copybara”Techniques for troubleshooting workflows.
Verbose Output
Section titled “Verbose Output”Increase logging verbosity:
java -jar copybara.jar migrate copy.bara.sky export -vjava -jar copybara.jar migrate copy.bara.sky export -vv # More verboseDry Run
Section titled “Dry Run”See what would happen without making changes:
java -jar copybara.jar migrate copy.bara.sky export --dry-runLocal Testing
Section titled “Local Testing”Use folder destination to preview output:
java -jar copybara.jar migrate copy.bara.sky export \ --folder-destination /tmp/outputThen inspect:
find /tmp/output -type fdiff -r /tmp/output expected/Validate Configuration
Section titled “Validate Configuration”Check config before running:
java -jar copybara.jar validate copy.bara.sky exportTest Transforms
Section titled “Test Transforms”Create a test workflow:
core.workflow( name = "test-transforms", origin = folder.origin(), destination = folder.destination(), authoring = authoring.overwrite("Test <test@example.com>"), transformations = [ # Your transforms here ],)Run locally:
java -jar copybara.jar migrate copy.bara.sky test-transforms \ --folder-origin /path/to/source \ --folder-destination /tmp/outputCheck State
Section titled “Check State”Find last synced commit:
# In destination repogit log --grep="GitOrigin-RevId" -1
# Shows:# GitOrigin-RevId: abc123def456Debug Globs
Section titled “Debug Globs”Test which files match:
# Temporarily use very specific includeorigin_files = glob(["src/specific-file.txt"])Then expand as needed.
Console Logging
Section titled “Console Logging”In dynamic transforms:
def _my_transform(ctx): ctx.console.info("Processing files...") for f in ctx.run(glob(["**"])): ctx.console.info("Found: " + f) return ctx.success()Save Output
Section titled “Save Output”Save console output to file:
java -jar copybara.jar migrate copy.bara.sky export \ --console-file-path copybara.log 2>&1 | tee copybara.logCommon Debug Scenarios
Section titled “Common Debug Scenarios”Check what files are included
Section titled “Check what files are included”java -jar copybara.jar migrate copy.bara.sky export \ --folder-destination /tmp/testfind /tmp/test -type fVerify replacements
Section titled “Verify replacements”java -jar copybara.jar migrate copy.bara.sky export \ --folder-destination /tmp/testgrep -r "old_text" /tmp/test # Should not findgrep -r "new_text" /tmp/test # Should findCheck commit message
Section titled “Check commit message”java -jar copybara.jar migrate copy.bara.sky export \ --folder-destination /tmp/testcd /tmp/testgit log -1Test regex patterns
Section titled “Test regex patterns”Use a regex tester or:
# Pythonimport repattern = r"your_pattern"text = "your text"print(re.findall(pattern, text))Workflow Info
Section titled “Workflow Info”Get information about a workflow:
java -jar copybara.jar info copy.bara.sky export