Skip to content
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

Unable to push to empty repository on GitHub #25

Closed
wDhTIG opened this issue Nov 17, 2017 · 13 comments
Closed

Unable to push to empty repository on GitHub #25

wDhTIG opened this issue Nov 17, 2017 · 13 comments
Assignees
Labels
Projects

Comments

@wDhTIG
Copy link

wDhTIG commented Nov 17, 2017

First of all: thanks for this wonderful library. It seems to be exactly what I need.

I am experimenting with this a bit (Firefox 57) and I can't get a simple clone-edit-commit-push cycle to work. What am I doing wrong. In the <head> of my html I have included isomorphic-git and browserfs as instructed. In the body I have a script tag containing:

git('.').clone('https://cors-buster-jfpactjnem.now.sh/github.com/wDhTIG/rthKRF');
fs.writeFile('README.md', 'Test', 'utf8', (err) => {
    if (err) throw err;
        console.log('The file has been saved!');
});
git('.').auth('mysecret')
        .add('README.md')
        .commit('Test commit')
        .push('master');

I get the following errors in the console log:

The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol.
git.html
Unhandled promise rejection
TypeError: l(...) is undefined
Stack trace:
e/<@https://unpkg.com/isomorphic-git:1:80863
n@https://unpkg.com/isomorphic-git:1:125272
f/<@https://unpkg.com/isomorphic-git:1:126316
o/</e[t]@https://unpkg.com/isomorphic-git:1:125448
i@https://unpkg.com/isomorphic-git:1:120912
i/<@https://unpkg.com/isomorphic-git:1:121012
B/</<@https://unpkg.com/isomorphic-git:1:273404
B/<@https://unpkg.com/isomorphic-git:1:273274
f@https://unpkg.com/isomorphic-git:1:257078
isomorphic-git:1:273747
Source map error: request failed with status 404
Resource URL: https://unpkg.com/isomorphic-git
Source Map URL: bundle.umd.min.js.map

@billiegoose
Copy link
Member

Aw wow! Thanks and congrats on being (to my knowledge) the first person to try using this library! You are certainly the first issue.

Hmm. Your example seems to illustrate some serious oversights in my documentation. I will try to improve that. I think what it needs is more interactive examples. Meanwhile, I'll try to build a jsfiddle for you.

@billiegoose
Copy link
Member

OK, so there's a bug where the code crashes if you try to push to a completely empty (new) repository on Github, which I'll try to address this week. But here's how your code would look, more or less:

BrowserFS.configure({ fs: "InMemory", options: {} }, function (err) {
  if (err) return console.log(err);
  window.fs = BrowserFS.BFSRequire("fs");
  main();
});

async function main () {
  await git('.').init();
  await git('.').config('remote.origin.url', 'https://cors-buster-jfpactjnem.now.sh/github.com/wmhilton/congenial-waffle');
  fs.writeFile('README.md', 'Test', 'utf8', async (err) => {
    if (err) throw err;
    console.log('The file has been saved!');
    await git('.').add('README.md');
    await git('.').commit('Test commit');
    await git('.').auth('mysecret').remote('origin').push('master'); // Here's where it crashes trying to push to an empty repo
  });
}

@wDhTIG
Copy link
Author

wDhTIG commented Nov 25, 2017

Thanks for your reply.
I've used github to create an initial commit with a README.md.
After using your suggested code to create a second commit, I get the following error in the browser console:

Failed to read git object with oid c932a85ce627b448152792a40b755f8c8e224fed

Is there anything I can do to help debugging this issue?

@wDhTIG
Copy link
Author

wDhTIG commented Nov 29, 2017

Would it be possible for you to create an example repository on github such that:

  • one can just clone it, and fix two lines in the settings (API key + repository name)
  • have a very basic website running on github pages (for example some buttons that run example queries)
    And as a bonus, people get to experiment via the console automatically.

This would provide a sort of skeleton upon which I could build further.
For example, as a first project, to test whether I get how this works, I would then try to evolve my clone into an online github editor, provide a basic file browser + codemirror frame for editing & writing commit messages.

@billiegoose
Copy link
Member

billiegoose commented Nov 30, 2017

I did have a very basic website & demo on CodeSandbox and wanted to give you a link after your first post, but when I went to get the link for you I discovered that my demo was broke: https://codesandbox.io/s/mj77r46xkp

I think it would be fair to say it's not really ready for people to use. :( My own fault. It's close. It's getting closer! I'll say January will be my 1.0 release that Just Works (TM).

However, it sounds like you are interested in building a file browser / code editor / IDE of the future, in which case if you're bold enough I'd love for you to alpha test https://github.com/wmhilton/nde It only works in very recent versions of Chrome and Firefox though.

Edit: right now nde is at https://nde.now.sh and has a painfully long installation process with cat gifs, but I'm eventually going to have a "works right away without a long installer experience" at https://wmhilton.github.io/nde

@billiegoose
Copy link
Member

One of the things I'm going to do, after talking with you and @CMCDragonkai, is to ditch the "fluent" API

git("dir").option("value").option("value").command("value")

that was supposed to be convenient, but in practice has been
a) difficult to debug and
b) confusing because options and commands look similar
for something more like this:

var repo = new Git(config);
await repo.command({
  option1: "value",
  option2: "value",
  option3: "value"
})

@wDhTIG
Copy link
Author

wDhTIG commented Nov 30, 2017

Hmmm, so I have left nde.now.sh running in Firefox 57 for over an hour, and it is still playing cat gifs...
Concerning my own plans: what I want to build is a combination of personal-wiki and graph-editor. So you have a graph (rendered by d3js or something) and all the nodes contain a bunch of text (markdown or something) a hyperlink from one piece of text to another would create a directed edge between the corresponding nodes in the graph. All of this should be backed by a git repo.

@billiegoose
Copy link
Member

Hmmm, so I have left nde.now.sh running in Firefox 57 for over an hour, and it is still playing cat gifs...

Oh no it shouldn't take that long. A minute tops. Sounds like you didn't get a progress bar. I mean, if you really want to try it out ASAP you can try closing the cache, unregistering the SW and refreshing... or just give me a few more weeks until I get all the kinks ironed out. :)

The wiki graph "mind map" editor sounds really cool, and is exactly the kind of creative project that I was hoping this library would enable! I'll help you get there. I'm limited by my day job to working on the project in the evenings and weekends, but I'm pretty confident that I'll have the new simpler API out by this weekend.

@billiegoose
Copy link
Member

@wDhTIG I moved the API documentation to https://wmhilton.github.io/isomorphic-git I still need to add examples. But meanwhile you can look at the test cases to get an idea.

@wDhTIG
Copy link
Author

wDhTIG commented Dec 4, 2017

Thanks! This looks great. I will see what I can do with it. I'll keep you updated.

@billiegoose
Copy link
Member

Just wanted to announce the new Gitter chat room: https://gitter.im/isomorphic-git/Lobby

And I am actively working on making an interactive tutorial on Github pages where you'll be able to run isomorphic-git in the console and play with a sample Github repo!

@billiegoose
Copy link
Member

Status Update

Pretty sure I still need to fix this bug

@billiegoose billiegoose changed the title Unable to push to GitHub Unable to push to empty repository on GitHub Mar 5, 2018
@billiegoose billiegoose self-assigned this Mar 18, 2018
@billiegoose billiegoose added this to To do in Kanban Jul 12, 2018
@billiegoose billiegoose moved this from To do to In progress in Kanban Jul 21, 2018
@billiegoose
Copy link
Member

I just confirmed I am able to push to an empty repository on Github:

$ isogit push --username=wmhilton --password=$GITHUB_TOKEN --url=https://github.com/wmhilton/empty
>> git.push({fs, dir: '.', "username":"wmhilton","password":"XXXXXXXXXXXXX","url":"https://github.com/wmhilton/empty"})
{
  "ok": [
    "unpack",
    "refs/heads/master"
  ]
}

Also, after adding a remote and creating a new branch, I was able to push that new branch:

$ isogit push --username=wmhilton --password=$GITHUB_TOKEN
>> git.push({fs, dir: '.', "username":"wmhilton","password":"XXXXXXXXXXX"})
{
  "ok": [
    "unpack",
    "refs/heads/newbranch"
  ]
}

Since I'd renamed this issue to "Unable to push to empty repository on GitHub" and that appears to not be a problem anymore, I shall close this issue. But continue to create new issues and to chat in Gitter as you encounter new obstacles!

Kanban automation moved this from In progress to Done Jul 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Kanban
  
Done
Development

No branches or pull requests

2 participants