Thanks to visit codestin.com
Credit goes to github.com

Skip to content

A higher-level wrapper around the Github API. Intended for the browser.

License

Notifications You must be signed in to change notification settings

captn3m0/github

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Github.js

Github.js provides a minimal higher-level wrapper around git's plumbing commands, exposing an API for manipulating GitHub repositories on the file level. It is being developed in the context of Prose, a content editor for GitHub.

Usage

Create a Github instance.

var github = new Github({
  username: "YOU_USER",
  password: "YOUR_PASSWORD",
  auth: "basic"
});

Or if you prefer OAuth, it looks like this:

var github = new Github({
  token: "OAUTH_TOKEN"
  auth: "oauth"
});

Repository API

var repo = github.getRepo(reponame);

Retrieve all available branches (aka heads) of a repository.

repo.listBranches(function(err, branches) {
  
});

Store contents at a certain path, where files that don't yet exist are created on the fly.

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

Not only can you can write files, you can of course read them.

repo.read('master', 'path/to/file', function(err, data) {
  
});

Move a file from A to B.

repo.move('master', 'path/to/file', 'path/to/new_file', function(err) {
  
});

Remove a file.

repo.remove('master', 'path/to/file', function(err) {
  
});

Listing all files of a repository is easy too.

repo.list('master', 'path/to/file', function(err, data) {
  
});

User API

var user = github.getUser();

List all repositories of the authenticated user.

user.repos(username, function(err, orgs) {
  
});

List organizations the autenticated user belongs to.

user.orgs(function(err, orgs) {
  
});

Show user information for a particular username. Also works for organizations.

user.show(username, function(err, user) {
  
});

List public repositories for a particular user.

user.userRepos(username, function(err, repos) {
  
});

List repositories for a particular organization. Includes private repositories if you are authorized.

user.orgRepos(orgname, function(err, repos) {
  
});

Tests

Github.js is automatically™ tested by the users of Prose. Because of that, we decided to save some time by not maintaining a test suite. Yes, you heard right. :) However, you can still consider it stable since it is used in production.

Change Log

O.6.X

Adds support for organizations and fixes an encoding issue.

O.5.X

Smart caching of latest commit sha.

0.4.X

Added support for OAuth.

0.3.X

Support for Moving and removing files.

0.2.X

Consider commit messages.

0.1.X

Initial version.

About

A higher-level wrapper around the Github API. Intended for the browser.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%