GithubHelp home page GithubHelp logo

git.hub's Introduction

Git.hub

A simple API in terms of querying github with C#, based on RestSharp.

Usage

Create a client instance

using Git.hub;
Client client = new Client();

Login

The recommended way to login is to use OAuth tokens provided by Github, as detailed on the API docs.

client.setOAuth2Token("0fd...");

You could, for example, display a webbrowser control to navigate to the site and listen to the related events for when a redirect to your given site happens, use the ?code=<code> with the following line:

OAuth2Helper.requestToken(client_id, client_secret, <code>

Albeit not recommended, logging in with Username and Password is possible:

client.setCredentials("mabako", "super duper password");

To retrieve the currently logged in user, use the following:

User user = client.getUser();

Repositories

To fetch repositories, the following lines of code should suffice your needs:

IList<Repository> repos = client.getRepositories("mabako");
IList<Repository> orgRepos = client.getOrganizationRepositories("github");

Repository repo = client.getRepository("mabako", "Git.hub");

/* Requires login */
IList<Repository> ownRepos = client.getRepositories();

Please take note that the latter includes all repositories you have access to, if you certainly want your own repos only filter for Repository.Owner.Login.

Simple Repository Actions

Fork the repo:

Repository forked = repo.CreateFork();

List branches:

IList<Branch> branches = repo.GetBranches();

Pull Requests

You can fetch all of the repo's pull requests or just one, use as fit.

IList<PullRequest> pullrequests = repo.GetPullRequests();
PullRequest pullrequest = repo.GetPullRequest(1);

Alternatively, a new pull request may be created with:

var pullrequest = repo.CreatePullRequest("mabako:new-feature", "master", "Subject", "Details...");

Take note that 'repo' is the repo in which the pull request is created, your own username is usually in the first parameter, along with your branch.

A few basic actions on pull requests are defined:

pullrequest.GetCommits();
pullrequest.Open();
pullrequest.Close();

/* This is the same */
var issue = pullrequest.ToIssue();
issue.GetComments();
pullrequest.GetIssueComments()

To reply to a pull request, fetch the issue first with ToIssue() and use

issue.CreateComment("My comment");

git.hub's People

Contributors

aorlov avatar cocytus avatar gerhardol avatar haldyr avatar jbialobr avatar kinddragon avatar mabako avatar mast-eu avatar mnaoumov avatar nn--- avatar oriash93 avatar pmiossec avatar russkie avatar sharwell avatar thimmy687 avatar thomaslevesque avatar

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.