jcabi-github icon indicating copy to clipboard operation
jcabi-github copied to clipboard

MkTrees.create() buggy format of storage

Open pgressa opened this issue 8 years ago • 2 comments

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, I expect that I got a response a newly created Tree t, with t.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.:

<trees>
<tree>
<path>"file.yaml"</path>
<sha>"783479c66f8769bd28121c2f27e98b5fb4b80ee3"</sha>
</tree>
<tree>
<path>"file2.yaml"</path>
<sha>"fa3c22b5da981e258d2fca6c6419f6d8d2d6e62a"</sha>
</tree>
</trees>

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

pgressa avatar Dec 05 '17 15:12 pgressa

@yegor256 please, pay attention to this issue

0crat avatar Dec 05 '17 15:12 0crat

@pgressa can you please show the code so that we can reproduce the bug and fix?

yegor256 avatar Dec 07 '17 09:12 yegor256