Code Monkey home page Code Monkey logo

github's People

Contributors

albertoborit avatar alundiak avatar aurelioderosa avatar captn3m0 avatar clayreimann avatar coderaiser avatar codygramlich avatar ctalau avatar darvin avatar deecewan avatar hazmah0 avatar iamdanfox avatar ingalls avatar j-rewerts avatar jayhjkwon avatar knsh14 avatar kpdecker avatar mattpass avatar max-mapper avatar michael avatar mironal avatar mtscout6 avatar otaviocx avatar randalmaia avatar randalpinto avatar raphink avatar strd6 avatar tamer1an avatar tricknotes avatar wjxhenry avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

github's Issues

Allow updating multiple trees

I am just calling write on each file in the folder individually but this seems to randomly cause github to return Unprocessable Entity errors.

Is there a reliable way to write an entire folder of files?

My full code is here: https://mod.it/rSZYmsjn/dev Thanks!

PS.

This library is awesome and pulling from github is working great for me.

Readme & updates

I'm helping clear the backlog of pull requests and issues at the moment, now about a third of the way thru them. If your issue/pull hasn't been dealt with yet, not to worry, it'll be dealt with pretty shortly.

Once these are all clear, I'll go through the readme.md file and code in general so all the whole API is spec'd and that'll probably be v0.9.

remove underscore?

Underscore is used all of seven times in the codebase, mostly for functions that plain JS already has. It would be incredibly nice if these seven bits were actually turned into plain JS so that github.js would just work as a standalone library

README-information is old.

Now,

var repo = github.getRepo(reponame);

this is, maybe

var repo = github.getRepo(username, reponame);

listBranches() only returns the last component of the branch path

After looking at the code, it looks like this was done intentionally, but I'm not sure why. I feel I should be able to pass the values returned by listBranches() to getRef() (appended to "heads/") without issue, but if I have a branch 'feature/foo', listBranches() will return 'foo', and getRef() will fail.

Adding new files using repo.write

I can update an existing file just using repo.write. The README says that files not existing in the repo are created on the fly. However, that doesn't seem to be working?

Looks like a path problem, because I get these 2 errors back...

OPTIONS https://api.github.com/repos//undefined/git/refs/heads/master?1345134920700 204 (No Content)
GET https://api.github.com/repos//undefined/git/refs/heads/master?1345134920700 404 (Not Found)

Notice there is no username or repo and a double slash after github.com/repos.

Can you confirm if there is a slight bug here?

Weird caching issue with our new _request implementation

@mattpass we've got a crazy crazy caching problem with our current XMLHttpRequest native implementation. I couldn't find out what's exactly happening here.

You need to use the updated github.js that I haven't commited yet because of this bug:

https://gist.github.com/3196019

The error can be reproduced like so:

var repo = github.getRepo("michael", "cmake_cdt7_stalled");

// Triggers GET: https://api.github.com/repos/michael/cmake_cdt7_stalled/git/refs/heads/prose-integration
repo.getRef('obu_cdt7_support', function(err, ref) {
  // Triggers DELETE: https://api.github.com/repos/michael/cmake_cdt7_stalled/git/refs/heads/prose-integration
  repo.deleteRef("heads/obu_cdt7_support", function(err) {
    // For some weired reason the delete request doesn't get started, request inspection in chrome reveals
    // it just returns the content from the previous GET request (from cache)
  });
});

That's what the request log looks like for the DELETE request. Expected is a 204 no-content (not from cache) that actually removes the ref but we get a 200 OK (from cache). Seems like the variation of the method (GET vs. DELETE) is not considered for the caching mechanism.

Request URL:https://api.github.com/repos/michael/cmake_cdt7_stalled/git/refs/heads/prose-integration
Request Method:DELETE
Status Code:200 OK (from cache)
Request Payload
{"user":"michael","name":"cmake_cdt7_stalled"}

Explain dependencies

As of now, this needs jQuery, underscore, and an implementation of Base64.encode as well to function. Please note them down as such in the readme.

I think the Base64 should be included with it, at least.

Simple write test failing

github = new Github({ username:'username', password:'password', auth:"basic"})

user = github.getUser();

repos = ''

user.repos(function(err,r) { repos = r; })

repo = repos[0]

repoforwrite = github.getRepo('username',repo.name)

repoforwrite.write('gh-pages','test','test','test', function(err){alert(err);});

500 Server Internal Error

repo.permissions

Object {admin: true, pull: true, push: true}

repoforwrite.listBranches(function(err,branches) { console.log(branches);})

undefined
gh-pages,master

repo.write throws "Update is not a fast forward" after first successful create

Using the example from the docs, I can successfully write to my repo.

// example write
repo.write('master', 'path/to/file', 'YOUR_NEW_CONTENTS', 'YOUR_COMMIT_MESSAGE', function(err) {});

But only the first save seems to work. The others return a 422 status with the following error. I did notice this prose ticket...wondering what the workaround there was?

{
  "message": "Update is not a fast forward",
  "documentation_url": "http://developer.github.com/v3"
}

authorize with github like at prose.io

I just love the "authorise with github" button at prose.io

Can I create something similar just using github.js, or do I need to pull in more things from prose?

I've been trying to get github.js working, using basic authentication and things like this:

var user = github.getUser();
var gist = github.getGist(3165654);

but in my chrome console I get the following:

gist
Github.Gist {read: function, create: function, delete: function, fork: function, update: function}
gist.read(function(err, gist) {

});
TypeError: undefined is not a function
get stack: function () { [native code] }
message: "undefined is not a function"
set stack: function () { [native code] }
__proto__: Error

Any help very much appreciated ...

Allow binary blobs

In order to safely transfer binary blobs/filtes, the API needs to use base64 encoding when appropriate. postBlob() however always uses "utf-8". So there needs to be either an additional argument in write() and postBlob() that specifies the encoding, or postBlob() needs to detect if the file is binary or not, and adjust the encoding automatically.

This little snippet seems to be able to detect binary data:

/[\x00-\x08\x0E-\x1F]/.test(data)

See http://stackoverflow.com/questions/1677644/detect-non-printable-characters-in-javascript

I'm currently dealing with similar issues in Prose: prose/prose#255

add @jlord as a maintainer

hey @michael I convinced @jlord to adopt this library -- she works at github and would be happy to dive in and help field issues and pull requests and make this lib more awesome

Remove repo.remove (or fix it, if it's still useful)

when I call the .remove() function, I keep getting these errors:

POST https://api.github.com/repos/Pomax/gh-blog/git/trees?1393981519258 422 (Unprocessable Entity) api.github.com/repos/Pomax/gh-blog/git/trees?1393981519258:1
POST https://api.github.com/repos/Pomax/gh-blog/git/commits?1393981519451 422 (Unprocessable Entity) api.github.com/repos/Pomax/gh-blog/git/commits?1393981519451:1
Uncaught TypeError: Cannot read property 'sha' of undefined 

The network responses for the failed URLs are

{
  "message": "Must supply tree.sha or tree.content",
  "documentation_url": "http://developer.github.com/v3/git/trees/#create-a-tree"
}

and

{
  "message": "Validation Failed",
  "documentation_url": "http://developer.github.com/v3/git/commits/#create-a-commit",
  "errors": [
    {
      "value": null,
      "resource": "Commit",
      "field": "tree",
      "code": "missing"
    }
  ]
}

respectively.

Authentication problem in IE9 and opera 12.16

Hello,

I'm using github.js for login api for my application. It works fine for chrome, firefox and safari and IE 10. I'm facing problem with IE9 and opera.

For IE 9, it is giving below error

after executing this line - xhr.open(method, getURL());, it is saying, access denied error.(Credentials are correct).

For opera, it is giving status value as 0. Can any one help me to resolve this issue.

Thanks,

Janardhan

Maruku can no longer handle headers in comments

This used to work, many months ago when I last edited one of my repositories, but it no longer seems to. I am not sure when this broke though.

bhollis/maruku#115

If this is going to be an long term issue, I can re-edit all my markdown, but if it is possible, I would like to know if this will be dealt with anytime soon

Thanks!

Alternative methods to avoid full tree hierachy request "?recursive=true"

There are three methods which requests full tree hierarchy ("?recursive=true"):

  1. this.getSha
  2. this.remove
  3. this.move

Sometimes it is very heavy request to get full tree hierarchy. Is it possible to introduce an alternative methods like:

// Remove a file from the tree by sha and path
// -------
this.remove2 = function(branch, path, sha, cb) {
_request("DELETE", repoPath + "/contents/" + path, {"message": "test commit", sha: sha, branch:branch}, cb, "json");
};

2.this.getSha
It is possible to use JSON request for the "/contents/" to get more information about the it:

this.contents2 = function(branch, path, cb) {
_request("GET", repoPath + "/contents/ref=" + branch, { path: path }, cb, "json");
};

Fix NPM registry

Could you please fix the package on NPM registry?

By running `npm install github-api' will install darvin's repository which is two versions old and not working properly.

Thanks

500 Internal Server Error and Access-Control-Allow-Origin

Is no one else getting similar errors (looks like Gaubee might)?

OPTIONS https://api.github.com/repos/muffintheman/tipsy/git/refs/heads?1359485598135 500 (Internal Server Error) github.js:48
XMLHttpRequest cannot load https://api.github.com/repos/muffintheman/tipsy/git/refs/heads?1359485598135. Origin ... is not allowed by Access-Control-Allow-Origin.

this library doesn't need Base64 in the client

all browsers, and all modern IE, come with the window.atob and window.btoa functions, and have done so for years, for base64 serialization/deserialization =)

Rather than trying to find Base64 in browser context, simply use window.atob(input) to form a base64 string.

This library doesn't work with the Github API v3

I tried running the following simple code:

var github = new Github({ token: ".....<keyhere>.....", auth: "oauth"});
var repo = github.getRepo("Pomax", "pomax.github.io");
repo.contents("master", "gh-weblog/content", function(err, result) { console.warn(err); console.log(result); }, true);
repo.remove("master", "gh-weblog/content/2013-10-31-11-26-36.json", function(err, result) { console.log(err, result); });

But this generates one error after another. The path handling in remove is not in line with the v3 API, in browser context the global vars are getting set wrong:

  • _ ends up being unknown on line 407, despite underscore having loaded
  • XMLHttpRequest gets overwritten in function scope rather than using var XMLHTTPRequest = (typeof XMLHTTPRequest === "undefined" ? false : XMLHTTPRequest);)
  • Base64 is not necessary at all in browser context (the atob() function already exists)

Even fixing those things, I get errors that the update call to git/trees is missing sha values; dir entires should have sha values as well, so I removed the filter that takes them out, and then the github API still throws up errors, so there are some problems here that prevent github.js from being usable with the API v3.

Use JSONP by default

This might sound weird, but it helps in two ways :

  • [Github API only accepts CORS requests from oauth registered domains](http://developer.github.com/v3/#cross-origin-resource-sharing]. This means to setup a working app that uses basic authentication, you will still have to setup an oauth application just to whitelist your domain. I found this out when I tested my app on something other than localhost.
  • Since the current github.js API does not pass the headers via callbacks, the response headers are neglected. This includes things like rate limits and pagination urls, which might be useful to developers, but are not passed. Using Jsonp would make sure that this is passed along as well.

As such, this would lead to losing nothing and making things a lot easier for the end users. For instance, anyone could just fork my repository, and it would automatically work for them at username.github.com/repo/ if I shift to gh-pages without them having to create an oauth application.

Create and delete repos

You can do most things to work with repos but there's no function to create them in the first place.

Would be great to have a function to create them, incl all the params (such as homepage, has wiki etc).

On the other end of the scale maybe a function to remove repos too?

merging

Hi
If I'm reading a file from a repo (repo.read) and then it changes before I write back (repo.write), the write disregards the changes and simply writes.
I would like for it to notice that the file has changed since reading and to do a merge - is that at all possible with the Github API? Is it possible with Github.js?

Thanks

This refers to yoavram/markx#34

move, remove generate erors or silent failed

var github = new window.github_api({ username: "aplib", password: "xxx", auth: "basic" }); var repo = github.getRepo('aplib', 'tmp'); repo.remove('gh-pages', '1/1.dat', function(err) { if (err) console.log(err); });

it's not worked. no error messages, no remove file.
in repo only folder '1' and file '1/1.dat'.

constructed with user/pass results in "TypeError: Cannot call method 'encode' of undefined"

used as a pure client side version (no nodejs):

var github = new Github({
  username: "Pomax",
  password: "......"
});
var repo = github.getRepo("Pomax", "bezierinfo");
repo.getTree("masster", function(err, data) { console.log(data); });

which gives me

TypeError: Cannot call method 'encode' of undefined

If there is something missing from this sequence of calls, the readme.md will need the additional information added, otherwise this is probably a bug.

Support Gitlab API

This is a placeholder issue to create a version of Github.js which works with Gitlab's HTTP API. The motivation is to allow Prose.io to work with self-hosted repos using Gitlab.

Gitlab is an opensource/self-hostable alternative to Github. It has a very similar data model (users, orgs, forks, etc), and an HTTP API of similar expressivity.

There is a public service at https://gitlab.com/ for testing.

Any other interest in such a port?

Unit test needed to prevent #14 regression

Hi there

Awesome library. I have one question though:

It seems like you're appending random query strings to the end of every API call, probably in order to make sure you get a non-cached response on every call.

However, the Gihub API implements a pretty smart HTTP caching, that is being ignored with this library. For people using it, it means that the rate-limit will get used much faster, and apps will try to reload content that is not updated.

Here's an example of what I mean:

/* Using JQuery
____________________________________________ */

$.ajax({
  url:"https://user:[email protected]/repos/user/repo",
  success: function(data) { console.log(data) }
});
// --> response 200 with content

$.ajax({
  url:"https://user:[email protected]/repos/user/repo",
  success: function(data) { console.log(data) }
});
// --> if called again within 60 seconds this call will never be made, 
//      as the Github API has HTTP cache of 60 seconds. If after 
//      60 seconds and data is not updated, it returns an empty 
//      304 not modified, which is much faster

/* Using github.js
____________________________________________ */

var github = new Github({
  username: "user",
  password: "pass",
  auth: "basic"
});
var repo = github.getRepo(user, repo);

repo.show(function(err, repo) { console.log(repo) });
// --> response 200 with content

repo.show(function(err, repo) { console.log(repo) });
// --> response 200 with content, no caching

repo.show(function(err, repo) { console.log(repo) });
// --> response 200 with content, no caching

I saw that you have "implemented smart caching" in a commit, so I'm not sure exactly what's going on. How is this library caching stuff?

Uncaught TypeError: undefined is not a function in github.js:32

While call write/read methods it show error like: Uncaught TypeError: undefined is not a function in github.js:32
i try like this bellow...
repo.read('master', 'README.md', function(err, data) {});
repo.write('master', ' Test/README.md ', 'This is my New comment', '1st commit', function(err) {});

maybe bug in write()

i'm trying to upload file to my repo

github = new Github
  username: "zh99998",
  password: <hidden>,
  auth: "basic"

repo = github.getRepo('zh99998', 'test')

repo.write 'master', '/README.markdown', 'test1', 'test2', (err)->
  console.log err

then it logs out null, and see Network, all are 200 OK / 201 Created, seems all well, when i go to github and see that repo, the commit is successful, but there's nothing in this commit, and file is not modified.

like this:
zh99998/test@d292be1

Stupid(?) question

Hi everyone. I only do JS for a couple of weeks now and could not find out, why the code

  this.show = function(username, cb) {
    var command = username ? "/users/"+username : "/user";

    _request("GET", command, null, function(err, res) {
      cb(err, res);
    });
  };

Works with

  ....show('dctr', myFunc);

and with

  ....show(myFunc);

Why doesn't command evaluate to something absurd and cb fails but myFunc is called in both cases? At least i would have expected something like

  cb = username ? cb : username;

Thanks in advance for anwers...

repo.remove throws error

when using repo.remove('gh-pages', 'file that exists', function(err) { console.error(err); }); I get the following error and callstack:

Uncaught TypeError: Cannot call method 'reject' of undefined -- github.js:532
(anonymous function) -- github.js:532
(anonymous function) -- github.js:347

I was trying to effect a "repo.replace" by first removing a file I know exists in the tree using repo.remove and then calling repo.write to put in a new copy with updated information, but the remove throws this error.

It appears that the _ var in https://github.com/michael/github/blob/master/github.js#L532 does not actually point to anything.

AMD support

@michael thanks for the great module. :)

What is the current status of AMD support with this module? I can't find anything as to where things stand for it atm.

In the project history, the only mention I can dig up so far is this: https://github.com/michael/github/pull/44/files.

Any reason as to when/why it was removed? Is there anything currently in the way of bring AMD support back?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.