Giter Site home page Giter Site logo

pulley's Introduction

Pulley

An Easy Github Pull Request Lander

Introduction

Landing a pull request from Github can be messy. You can push the merge button, but that'll result in a messy commit stream and external ticket trackers that don't automatically close tickets.

Additionally you can pull the code and squash it down into a single commit, which lets you format the commit nicely (closing tickets on external trackers) - but it fails to properly close the pull request.

Pulley is a tool that uses the best aspects of both techniques. Pull requests are pulled and merged into your project. The code is then squashed down into a single commit and nicely formatted with appropriate bug numbers and links. Finally the commit is pushed and the pull request is closed with a reference to the commit.

Getting Started

Install

Make sure you have Node.js and then run npm install -g pulley in Terminal.

Use

Open the target repo in Terminal and run pulley PID, where PID is the Pull Request ID.

Example

Running pulley 332 on the jQuery repo yielded the following closed pull request and commit.

Contribute and Test

In order to test your changes to pulley, you need the ability to:

  • Open and close pull requests
  • Push to a branch on a repo

Essentially, you need your own repo, and the ability to issue pull requests against that repo. Fortunately, GitHub allows you to issue pull requests against your own repo from one branch to another. Here are the steps:

  1. Fork pulley
  2. Checkout the test branch
  3. Branch off from the test branch to another branch named test-1
  4. Create a commit on the test-1 branch
  5. Publish the test-1 branch
  6. Push the commit to the test-1 branch on your fork of pulley
  7. Open a pull request from test-1 to test on your own repo
  8. Use pulley to merge your pull request, and ensure everything went smoothly
  9. Submit your real pull request with your changes

Please lend a hand!

pulley's People

Contributors

doublerebel avatar eddiemonge avatar grahams avatar jeresig avatar krinkle avatar mikesherov avatar nschonni avatar rkatic avatar rwaldron avatar sindresorhus avatar supahgreg avatar vastbinderj 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

pulley's Issues

Review changes before committing

We should have a flag to make it possible to pause and review changes before committing.

Maybe --review?

When the user is done she can just hit enter or something to continue.

Override remote from CLI

upstream is the commonly used name, but not everyone uses that name, or I might have 2 remotes. There should be an way to override the remote on a case by case basis.

Example:

pulley 123 --remote 'origin'

Testing for errors by string compare on stderr fails with git commands.

Pulley uses string analysis of stderr to detect errors. Unfortunately git sends normal output to stderr for many of its commands, eg including fetch
http://git.661346.n2.nabble.com/Bugreport-Git-responds-with-stderr-instead-of-stdout-td4959280.html

When pulley analyzes stderr, any thing it looks for could be in the normal output.

In particular consider this normal output:

From https://github.com/johnjbarton/traceur-compiler
 * branch            getProtoParent-errors -> FETCH_HEAD
Switched to branch 'master'

and the test in pulley:

                } else if ( /error/.test( stderr ) ) {

and you can see that any branch with the string 'error' will break pulley. And I don't know about you, but I often have branches with 'error' in them, as I fix bugs.

git should send non-zero error code for real errors and pulley could check those with the first arg to the exec callback.

write unit tests

untested code = broken code. Main challenge is making a mock object for the github API.

fail if pull can't be automerged

Github provides whether or not a PR can be automerged. Pulley will fail catastrophically if it attempts to merge a PR that can't be automerged. We should handle this gracefully.

Support for use behind a proxy

Currently, when I try to use pulley behind a corp proxy I get

Error: Error: getaddrinfo ENOTFOUND

I've tried changing the request require to:

request = require("request").defaults( { 'proxy': process.env.HTTP_PROXY } )

but that just changes the message to

Error: Error: Hostname/IP doesn't match certificate's altnames

Add support for Github Enterprise

It looks like Pulley is currently hardcoded to use the public github, but I would like to use it with my company's internal Github instance. It would be nice if I could point it towards the internal instance via a ~/.pulleyrc or command line arg.

better error checking when push happens

As it stands, after the squashed commit is attempted to be pushed to the remote, pulley doesn't check that this was done successfully before leaving a comment and closing the original pull request. This is bad.

Use gh-NNN for Github issue/pull

Since jQuery uses #NNNN for referring to Trac tickets at bugs.jquery.com it's confusing to use the same nomencature for the Github issues as well. Supposedly Github recognizes gh-NNNN and using that would eliminate the confusion.

Add issue number from CLI

Currently when you use pulley, it will search through the commit message for issue numbers. But a lot of times when you get pull request, they don't mention the issue number in the commit. Would be useful to specify the issue number in the CLI.

Example:

pulley --issue 123

better documentation for the "done" option

When something goes wrong at certain stages of using pulley, the repo is left in a state that can be retried using an additional parameter to pulley. This should be documented better.

Override remote from CLI

upstream is the commonly used name, but not everyone uses that name, or I might have 2 remotes. There should be an way to override the remote on a case by case basis.

Example:

pulley 123 --remote 'origin'

Add configuration option for commit msg format

Right now it is hardcoded on line 221:

                msg = "Close GH-" + id + ": " + pull.title + ".",

jQuery projects usually prefer the format of "Landed pull request #{id}: {title}". Maybe add a config option for this with a a $1 and $2 as placeholder for id and pull.title.

Crash when fetching data

It is unable to fetch details for more repos and sometimes same repo also if the date range chosen is more than 7 days. Getting the below when All repos flag is selected
Screenshot 2023-10-25 at 2 20 17 PM

Validation fails when creating credentials

Did a fresh npm install -g of pulley

In my project, when I run pulley 74 it asks for first time credentials but fails saying:

Validation Failed. Try again.

/usr/local/lib/node_modules/pulley/pulley.js:63
            var auth = encodeURIComponent( result.username ) + ":" + encodeURIComponent
                                                 ^
TypeError: Cannot read property 'username' of undefined
    at /usr/local/lib/node_modules/pulley/pulley.js:63:41
    at /usr/local/lib/node_modules/pulley/node_modules/prompt/lib/prompt.js:316:20
    at /usr/local/lib/node_modules/pulley/node_modules/prompt/node_modules/utile/node_modules/async/lib/async.js:136:21
    at assembler (/usr/local/lib/node_modules/pulley/node_modules/prompt/lib/prompt.js:282:18)
    at /usr/local/lib/node_modules/pulley/node_modules/prompt/lib/prompt.js:322:20
    at /usr/local/lib/node_modules/pulley/node_modules/prompt/lib/prompt.js:510:14
    at onError (/usr/local/lib/node_modules/pulley/node_modules/prompt/node_modules/read/lib/read.js:94:12)
    at Interface.<anonymous> (/usr/local/lib/node_modules/pulley/node_modules/prompt/node_modules/read/lib/read.js:66:5)
    at Interface.EventEmitter.emit (events.js:92:17)
    at Interface._ttyWrite (readline.js:620:16)

I know I've typed my username but it doesn't look like it's making it to the result object.

remove need for silly setTimeouts everywhere

Currently, windows nodeJS has a weird issue that I need to look into further. Basically, I was getting strange errors up until I tried wrapping the API calls in setTimeout's on a whime that it was a threading issue.

That solved the problem, so hey, I went with it. This is obviously silly, and a permanent, sane fix needs to be implemented. PATCHES WELCOME!

Nothing to commit, working directory clean

I'm getting this message on a pulley 9

# On branch pull-9
nothing to commit, working directory clean

Here is the full call and output

pulley 9
Initializing... done.
Getting pull request details... done.
Pulling and merging results... done.
Getting author and committing changes... # On branch pull-9
nothing to commit, working directory clean

The origin/upstream repository has not had any commits since the pull request was initiated.

The pull-9 branch remains after the call. The modifications visible on GitHub are nowhere to be seen: neither the on pull-9 branch status or commit logs.

I welcome any advice or suggestions to get pulley working like I expect it.

migrate "done" option to "--done"

This will allow us to not rely on argument order for CLI parsing (in case a branch was named "done"). This is a current blocker for extending the CLI stuff.

Add "preferGlobal" to package.json / README.md

First: great work this is exactly the kind of additional workflow tooling needed on Github.

Just a small change so I thought I'd just drop the suggestion instead:

  1. You have a bin property in your package.json
  2. Running [sudo] npm install pulley -g will ensure that pulley PID works globally (users won't have to do node pulley.js everywhere.
  3. Adding
{
  "preferGlobal": true
}

to you package.json will ensure users see a warning when they run npm install pulley. This is really useful for gently showing users that your library is really more of a utility. I do this in forever: https://github.com/indexzero/forever/blob/master/package.json#L3

trouble with 2 factor authentication

If I supply an token , it says Not Found. Try again.
But if I supply password, it says Must specify two-factor authentication OTP code.. Try again.

Repos with hyphens in names don't work

I have a few repos with hyphens in the names (grahams/nicecast-trackupdate; for instance) and these fail in pulley. This is because the \w+ doesn't match hyphens. Pull request TK.

don't store github passwords in plain text

In order to upgrade to github API v3, unless we start using OAUTH tokens, username and password are required for api calls. This is obviously less than ideal. What's worse is that the rewrite stores them in plaintext. A better solution is needed.

Use "git config" instead of config.json for all settings

Now that we save the oAuth token in git config, I'm thinking it might be useful to store the rest of the settings in the same way.

Pros

  • Global defaults which can be easily overridden in Terminal. Currently it's not very intuitive where the config.json is.
  • Per repo settings overrides possible.
  • git will manage the correct loading for us, since it will always first try the local, then the global, then the system config.
  • Currently the config.json is overridden on each update which is really bad...

We could then allow every option to be overridden on runtime too. This would solve #21.

Colors

Pulley need some coloring on done/fail (green/red) events to make them stand out ๐ŸŒˆ

screenshot

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.