Git Product home page Git Product logo

github-pull-request's Introduction

github-pull-request

waffle.io's way of sending automagical pull requests for our badges. Please don't use this to send spam pull requests, no one likes that!

For more details, read the accompaning blog post.

Getting started

npm install

This project isn't consumable as is (as an npm module, for example). It's also very specific to waffle.io, this constructs a Pull Request to embed the waffle badge into someone's readme.

Environment dependencies

This code assumes there are two environment varibles set:

APPLICATION_PUBLIC_REPO_ACCESS_TOKEN: this is a GitHub access token that has permissions to interact with the waffle.io public repo. These permissions are required to create a fork of someone's repo.

APPLICATION_ACCESS_TOKEN: this is a GitHub access token with no permissions. It's used to make requests to public repos to fetch their readme file. You can reuse APPLICATION_PUBLIC_REPO_ACCESS_TOKEN, although it's more permissions than you need for this action.

Example

Here's how waffle uses this, in the context of an express route.

app.get '/:username/:repoName/pull', RouteHelpers.checkAuthForPullRequest, (req, res) ->
  pullRequestHandler = new PullRequestHandler
    username: req.params.username
    repoName: req.params.repoName
    requestingUsername: req.session.username
 
  pullRequestHandler.sendBadgePullRequest()
    .then =>
      res.json
        success: true
    .fail (error) =>
      res.json
        success: false
 
    .done()

The RouteHelpers.checkAuthForPullRequest middleware checks if waffle's logged in user is a collaborator of the project we're sending a pull request for, to protect our users from pull request spam.

Running tests

grunt to compile coffeescript

grunt test to run tests

github-pull-request's People

Contributors

homeyer avatar waffle-with-pears 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.