Sha256: 951a1bfa80f9d442d0ea0b7bde19895c83aaa85370fe1490dec82c9e77086821
Contents?: true
Size: 1.11 KB
Versions: 1
Compression:
Stored size: 1.11 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 directory = specified_directory || current_directory repo = Rugged::Repository.new(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.2 | lib/upstreamer/cli.rb |