patchtree

package
v0.0.0-...-6b15219 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package patchtree is a simple library that knows how to interpret a folder structure of jd diffs and apply them on top of a base.

test/
	base.json
	after_move/
	modification.patch
	sanitization/
	modification.patch
	hidden/
		modification.patch
	nonempty/
		modification.patch

Given a path relative ot the current binary, it walks backwards up the folder, ensuring that a modification.patch exists in each directory until it finds a base.json. Then it applies forward all of the modification.patches to give you the final composed json blob result.

patchtree-helper is a simple cli utility that wraps the functionality in this package.

Index

Constants

View Source
const BaseJSONName = "base.json"

BaseJSONName is the name of the base json file at the root of the directory tree.

View Source
const ExpandedJSONName = "node.expanded.json"

ExpandedJSONName is the name of the file that represents the entire expanded json blob at a given part of the tree, created by `expand`.

View Source
const PatchName = "modification.patch"

PatchName is the name of the patch in each sub-folder that modifies the json in the tree above it.

Variables

This section is empty.

Functions

func CleanTree

func CleanTree(rootPath string) (numAffectedFiles int, err error)

CleanTree goes through each node, and if modification.json conceptually matches node.expanded.json, then removes node.expanded.json.

func ContractTree

func ContractTree(rootPath string) (numAffectedFiles int, err error)

ContractTree goes through each node in the parse tree and where it finds a node.expanded,json, re-derives and overwrites the "modification.patch". Used as part of a workflow to modify base.json: run ExpandTree, modify base.json, then ContractTree.

func ExpandTree

func ExpandTree(rootPath string) (affectedFiles int, err error)

ExpandTree expands all of the nodes in the patchtree, applying the chains of modification and created an node.expanded.json in each node. Used in a workflow to modify base.json: run this commeand, then modify base.json, then run ContractTree.

func JSON

func JSON(path string) ([]byte, error)

JSON returns the patched json blob impplied by that directory structure or an error if something doesn't work. See the package doc for more.

func MustJSON

func MustJSON(path string) []byte

MustJSON is the same as JSON, but if it would have returned an error, panics istead.

Types

This section is empty.

Directories

Path Synopsis
cmd
patchtree-helper
patchtree-helper is a simple command that wraps patchtree.ExpandTree and ContractTree.
patchtree-helper is a simple command that wraps patchtree.ExpandTree and ContractTree.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL