Sha256: 4e91221775eed90662fd32a25afdb78c1e40f5720840335423ef31185baacabc

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

module GitPrettyAccept
  class App
    include Methadone::Main
    include Methadone::CLILogging

    main do |branch|
      options[:edit] = true if options[:edit].nil?

      our = Git.open('.')
      source_branch = our.branches.find(&:current).to_s

      commands = [
        "git pull",
        "git checkout #{branch}",
        "git rebase #{source_branch}",
        "git checkout #{source_branch}",
        "git merge --no-ff #{options[:edit] ? '--edit' : '--no-edit'} #{branch}",
        "git push",
        "git branch -D #{branch}",
        "git push origin :#{branch}"
      ]

      commands.each_with_index do |command, i|
        puts "\n#{command}"
        unless system(command)
          puts "\nDue to the error above, the following commands were not executed: "
          puts commands[i + 1, commands.size].join("\n")
          exit!
        end
      end
    end

    description "Accept pull requests, the pretty way"

    on "--[no-]edit", "Edit merge message before committing. (Default: --edit)"

    arg :branch

    version GitPrettyAccept::VERSION

    use_log_level_option
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
git_pretty_accept-0.1.2 lib/git_pretty_accept/app.rb