-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assorted 'ipfs object patch' cleanups #1407
Commits on Jun 20, 2015
-
test/sharness/t0051-object.sh: Collect OUTPUT tests together
Pull the independent multi-layer test added in d585e20 (allow patch add-link to add at a path, 2015-06-19, #1404) out into a separate block, so it's easier to read the single-layer tests that share the OUTPUT variable. License: MIT Signed-off-by: W. Trevor King <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 3f90ef4 - Browse repository at this point
Copy the full SHA 3f90ef4View commit details
Commits on Jun 21, 2015
-
core/commands/object: Intermediate-node creation for patch add-link
Because: ipfs object patch $ROOT add-link a/b/c $FILE is a lot easier than: EMPTY=$(ipfs object new unixfs-dir) && A=$(ipfs object patch $EMPTY add-link b $EMPTY) && R=$(ipfs object patch $ROOT add-link a $A) && ipfs object patch $R add-link a/b/c $FILE and the long form isn't even checking to see if the original $ROOT has descendents a or a/b. Note that these are just Merkle nodes, not Unix-FS directories, because 'ipfs object ...' is a Merkle-level tool. I'd like to make this flexible enough that we could have a Unix-FS-level 'ipfs file patch ...' with similar semantics except that it operates on Unix-FS-level nodes (e.g. it creates intermediate *directories*, turns directories into files if you use 'set-data', manages the '*-data' commands without clobbering the type information unixfs stores in Data, etc.). But I don't want that Unix-FS abstraction stuff sneaking into the Merkle-level command we're working on here. Now that insertNodeAtPath takes a *dag.Node to insert instead of a key.Key, and it can both add and remove (if toinsert is nil) links, there wasn't much need for the addLink helper. This commit just inlines (and extends to removal) that functionality in insertNodeAtPath. The '$(<file)' constructs differ from this file's previous '$(cat file)' usage, but it's always good to remove useless cats ;). I adjusted the existing '$(cat file)' call while I was at it. License: MIT Signed-off-by: W. Trevor King <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 8123253 - Browse repository at this point
Copy the full SHA 8123253View commit details -
core/commands/object: Add bubbling to rm-link
And now that we have several multi-layer patch tests, disambiguate the name of the add-without-autocreation test. License: MIT Signed-off-by: W. Trevor King <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 56953b2 - Browse repository at this point
Copy the full SHA 56953b2View commit details -
core/commands/object: List all actions and their arguments for 'patch'
Also fix a copy/paste error in an appendDataCaller error messages so it references append-data instead of set-data. License: MIT Signed-off-by: W. Trevor King <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 8198804 - Browse repository at this point
Copy the full SHA 8198804View commit details -
t0051: Add patch set-data tests
The "raw bytes as a command-line argument" UI makes it difficult to do some things. For example, I wasn't able to figure out a way to use $ ipfs object patch $EMPTY set-data "$(<set_data_expected)" to add data from a file that had a trailing newline (which is why I ended up using printf to write a file without a trailing newline). License: MIT Signed-off-by: W. Trevor King <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 078705f - Browse repository at this point
Copy the full SHA 078705fView commit details -
t0051: Add patch append-data tests
Setting the append-to-existing test up to avoid duplicating the expected content was too much trouble, so I'm just hard-coding the partial strings in the append-data calls. License: MIT Signed-off-by: W. Trevor King <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for ebc9a39 - Browse repository at this point
Copy the full SHA ebc9a39View commit details -
core/commands/object: Centralize some patch argument processing
The functionality contained in hear (managing links and data, bubbling changes) is useful stuff that folks will likely want to call directly from other Go code (e.g. I'm about to combine rm-link and add-link to produce a replace-link action). It's easier to do that when the handlers stick to more primitive IPFS objects (e.g. DAGServices and Merkle nodes) than it would be if they used higher level stuff (e.g. Request objects, arrays of argument strigns). License: MIT Signed-off-by: W. Trevor King <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 633a6e7 - Browse repository at this point
Copy the full SHA 633a6e7View commit details -
core/commands/object: Return *dag.Node from patch helpers
The functionality contained in hear (managing links and data, bubbling changes) is useful stuff that folks will likely want to call directly from other Go code (e.g. I'm about to combine rm-link and add-link to produce a replace-link action). It's easier to do that when the handlers stick to more primitive IPFS objects (e.g. dag.Nodes) than it would be if they used higher level stuff (e.g. key.Keys). Now that it would have been operating at a more fundamental level, I removed the rmLinkCaller helper entirely and call insertNodeAtPath directly to handle that case. This commit also shifts some common code outside of the switch statement to make the switch cases easier to read and avoid duplicating the same procedure within each case. License: MIT Signed-off-by: W. Trevor King <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 3bf5826 - Browse repository at this point
Copy the full SHA 3bf5826View commit details -
core/commands/object: Add replace-link action to patch
I rarely want to add duplicate links with the same name. This new action ensures that the only link at the specified path is the one you just added, regardless of whether or not there was already a link at that path. License: MIT Signed-off-by: W. Trevor King <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 63a92cb - Browse repository at this point
Copy the full SHA 63a92cbView commit details -
core/commands/object: Adjust patch rm-links to remove all matching links
Instead of stopping after the first one. This catches the implementation up to the rm-link explanation in the ShortDescription. License: MIT Signed-off-by: W. Trevor King <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for ef1e8ad - Browse repository at this point
Copy the full SHA ef1e8adView commit details