Sha256: b2a412d3da2ad9969ae46fc65205d9513c9d79a0f43f37d13b6c6f8089620634
Contents?: true
Size: 1.14 KB
Versions: 1
Compression:
Stored size: 1.14 KB
Contents
# encoding: utf-8 require 'octokit' require 'rugged' module Upstreamer class CLI def self.run(argv = ARGV) self.new(argv).run end def initialize(argv = ARGV) @argv = argv end def run forked_repository_directory = specified_directory || current_directory repo = Rugged::Repository.new(forked_repository_directory) if repo.remotes['upstream'] puts "Error: Remote 'upstream' already exists. (#{repo.remotes['upstream'].url})" return end remote = repo.remotes['origin'] # https://github.com/meganemura/bundler.git username_repository = remote.url[/github.com\/(.*)\.git/, 1] # meganemura/bundler repository = Octokit.repository(username_repository) unless repository.fork? puts 'Error: this repository is not forked repository' return end upstream_url = repository.parent.clone_url repo.remotes.create('upstream', upstream_url) puts "git remote add upstream #{upstream_url}" end def specified_directory @argv.first end def current_directory Dir.pwd end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
upstreamer-0.0.1 | lib/upstreamer/cli.rb |