Github user nikhilkh commented on a diff in the pull request:

    https://github.com/apache/cordova-coho/pull/78#discussion_r30699407
  
    --- Diff: src/merge-pr.js ---
    @@ -0,0 +1,62 @@
    +
    +var flagutil = require('./flagutil');
    +var optimist = require('optimist');
    +var shelljs = require('shelljs');
    +var executil = require('./executil');
    +var gitutil = require('./gitutil');
    +var superspawn = require('./superspawn');
    +
    +module.exports = function *(argv) {
    +    var opt = flagutil.registerHelpFlag(optimist);
    +    opt.options('pr', {
    +            desc: 'PR # that needs to be merged',
    +            demand: true
    +        }).options('remote', {
    +           desc: 'Named remote for the github apache mirror',
    +           demand: true  
    +        }).options('pretend', {
    +            desc: 'Don\'t actually run commands, just print what would be 
run.',
    +            type:'boolean'
    +        });
    +    argv = opt
    +        .usage('Merges the pull request to master\n' +
    +        '\n' +
    +        'Usage: $0 merge-pr --pr 111 --remote mirror')
    +        .argv;
    +   if (argv.h) {
    +        optimist.showHelp();
    +        process.exit(1);
    +   }
    +   yield gitutil.stashAndPop("", function*() {
    +       yield executil.execOrPretend(executil.ARGS('git checkout master'), 
argv.pretend);
    +    
    +       yield executil.execOrPretend(executil.ARGS('git pull origin 
master'), argv.pretend);
    +       
    +       yield executil.execOrPretend(['git', 'fetch', '-fu', argv.remote,
    +            'refs/pull/' + argv.pr + '/head:pr/' + argv.pr], argv.pretend);
    +    
    +       try {
    +            yield executil.execHelper(executil.ARGS('git merge --ff-only 
pr/' + argv.pr),
    +                /*silent*/ true, /*allowError*/ true, argv.pretend);
    +       } catch (e) {   
    +           if (e.message.indexOf('fatal: Not possible to fast-forward, 
aborting.') > 0) {
    +               // Let's try to rebase
    +               yield executil.execOrPretend(executil.ARGS('git checkout 
pr/' + argv.pr), argv.pretend);
    +               
    +               yield executil.execOrPretend(executil.ARGS('git pull 
--rebase origin master'), argv.pretend);
    +               
    +               yield executil.execOrPretend(executil.ARGS('git checkout 
master'), argv.pretend);
    +               
    +               yield executil.execOrPretend(executil.ARGS('git merge 
--ff-only pr/' + argv.pr), argv.pretend);
    +               
    +               var commitMessage = yield 
executil.execOrPretend(executil.ARGS('git log --format=%B -n 1 HEAD'), 
    +                    argv.pretend);
    +               
    +               yield executil.execOrPretend(['git', 'commit', '--amend', 
'-m',  
    --- End diff --
    
    I expect the committer to either ask the author to split commits to a 
meaningful set or do an interactive rebase after `merge-pr`. I have logged a 
line at the end requesting the committer to do so if needed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org

Reply via email to