-
Notifications
You must be signed in to change notification settings - Fork 24
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
Add create tree method #71
Conversation
This makes some changes to the `internal` `send` method to accept an `Encodable` but no public API changes. I’m not sure about the name `NewTree` for the internal type encoded in the request – any ideas?
Sources/Tentacle/Client.swift
Outdated
/// Create a tree in a repository | ||
public func create(tree: [Tree.Entry], basedOn base: String?, in repository: Repository, inBranch branch: String? = nil) -> SignalProducer<(Response, FileResponse), Error> { | ||
let newTree = NewTree(entries: tree, base: base) | ||
return send(newTree, to: .tree(owner: repository.owner, repository: repository.name, recursive: false, ref: nil), using: .post) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is supposed to be ref: branch
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, the branch argument should not be there. The tree
endpoint is used for both getting and creating a tree, where the path takes the following formats respectively:
/repos/:owner/:repo/git/trees/:sha
/repos/:owner/:repo/git/trees
when creating the tree, the base is part of the NewTree
, rather than a ref for Endpoint.tree
.
We could create a new Endpoint
createTree
if you think this would be clearer.
Sources/Tentacle/Tree.swift
Outdated
|
||
internal func encode() -> JSON { | ||
var payload: [String: JSON] = [ | ||
"tree": .array(entries.map{ $0.encode() }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a space between map
and {
?
Looks good to me, apart from the error above. 👍 I have some changes I want to make to the API as a whole, but I'll wait for this PR before I try to make any changes. |
What do you have in mind for the API changes? I'd like to add support for blobs next. These are interesting because they can be fetched as raw content, or as JSON describing the blob. The core |
I want to move to a value-based approach like I mentioned in my talk at the functional swift conference. I'm currently working on what that API should be exactly—and how much, if any, should reside in a separate framework. |
I was hoping you'd say that 😀 |
This makes some changes to the
internal
send
method to accept anEncodable
but no public API changes.I’m not sure about the name
NewTree
for the internal type encoded in the request – any ideas?