jcabi / jcabi/jcabi-github

MkTrees.create() buggy format of storage

Open
#1,344 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
307
Forks
144
Avg merge
1d 22h
Merged PRs (30d)
14

Description

I don't know whether I understand the usage of Mk* objects correctly, but I chose this library because it allows me to write tests instead of real interaction with GitHub. But the MK* objects are behaving oddly although the idea behind is smart.

Mine use case is that I would like to prepare some state of a repo and interact with it. For this I need to create Tree and Commits and Blobs.

While I'm trying to on [create-a-tree](https://developer.github.com/v3/git/trees/#create-a-tree), I expect that I got a response a newly created Tree t, with t.json() =>
```json
{
"sha": "cd8274d15fa3ae2ab983129fb037999f264ba9a7",
"url": "https://api.github.com/repos/octocat/Hello-World/trees/cd8274d15fa3ae2ab983129fb037999f264ba9a7",
"tree": [
{
"path": "file.rb",
"mode": "100644",
"type": "blob",
"size": 132,
"sha": "7c258a9869f33c1e1e1f74fbb32f07c86cb5a75b",
"url": "https://api.github.com/repos/octocat/Hello-World/git/blobs/7c258a9869f33c1e1e1f74fbb32f07c86cb5a75b"
}
]
}
```
But instead I get the `tree` array with all objects instead of something similar to example above. Furthermore the return statement in MkTrees.create returns not the tree but the first sha of file in the tree `this.get(trees.getJsonObject(0).getString("sha"));` which tries to act as a Tree, but it's file :/.

When checking the XML structure then it clearly shows that it probably real bug as the file is not a tree, but actually the object.:
```xml

"file.yaml"
"783479c66f8769bd28121c2f27e98b5fb4b80ee3"

"file2.yaml"
"fa3c22b5da981e258d2fca6c6419f6d8d2d6e62a"

```

Is this a bug or am I using this library in a wrong way?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.