Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Errors when trying to install thor tasks #1

Open
kristianmandrup opened this Issue · 0 comments

1 participant

@kristianmandrup

$ sudo gem install thor
...
$ git clone git://github.com/mislav/thor-tasks.git
Initialized empty Git repository in /Users/kristianconsult/my_rails/rails3_apps/demos/tasks/thor-tasks/.git/
remote: Counting objects: 15, done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 15 (delta 3), reused 15 (delta 3)
Receiving objects: 100% (15/15), done.
Resolving deltas: 100% (3/3), done.
kristian-mandrups-macbook-pro:tasks kristianconsult$ cd thor-tasks
kristian-mandrups-macbook-pro:thor-tasks kristianconsult$ thor list
WARNING: unable to load thorfile "/Users/kristianconsult/my_rails/rails3_apps/demos/tasks/thor-tasks/github.thor": /Users/kristianconsult/my_rails/rails3_apps/demos/tasks/thor-tasks/github.thor:76: syntax error, unexpected ':', expecting keyword_then or ',' or ';' or '\n'
when %r|^git://github.com/([^/]+/[^/]+)$|: $1.split('/')
^
/Users/kristianconsult/my_rails/rails3_apps/demos/tasks/thor-tasks/github.thor:77: syntax error, unexpected keyword_when, expecting keyword_end
when %r|^(?:ssh://)?(?:git@)?gith...
^
/Users/kristianconsult/my_rails/rails3_apps/demos/tasks/thor-tasks/github.thor:77: syntax error, unexpected ':', expecting keyword_end
...@)?github.com:([^/]+/[^/]+)$|: $1.split('/')
... ^
/Users/kristianconsult/my_rails/rails3_apps/demos/tasks/thor-tasks/github.thor:103: syntax error, unexpected keyword_end, expecting $end
No Thor tasks available
kristian-mandrups-macbook-pro:thor-tasks kristianconsult$ thor install http://github.com/mislav/thor-tasks/tree/master/github.thor?raw=true
WARNING: unable to load thorfile "/Users/kristianconsult/my_rails/rails3_apps/demos/tasks/thor-tasks/github.thor": /Users/kristianconsult/my_rails/rails3_apps/demos/tasks/thor-tasks/github.thor:76: syntax error, unexpected ':', expecting keyword_then or ',' or ';' or '\n'
when %r|^git://github.com/([^/]+/[^/]+)$|: $1.split('/')
^
/Users/kristianconsult/my_rails/rails3_apps/demos/tasks/thor-tasks/github.thor:77: syntax error, unexpected keyword_when, expecting keyword_end
when %r|^(?:ssh://)?(?:git@)?gith...
^
/Users/kristianconsult/my_rails/rails3_apps/demos/tasks/thor-tasks/github.thor:77: syntax error, unexpected ':', expecting keyword_end
...@)?github.com:([^/]+/[^/]+)$|: $1.split('/')
... ^
/Users/kristianconsult/my_rails/rails3_apps/demos/tasks/thor-tasks/github.thor:103: syntax error, unexpected keyword_end, expecting $end
Your Thorfile contains:
#!/usr/bin/env ruby

class Github < Thor
desc "track []", "track a fork belonging to "
def track(user, branch_name = nil)
branch_name ||= user
git %(remote add #{user} git://github.com/#{user}/#{project_name}.git)
git %(fetch --no-tags #{user} master:refs/remotes/#{user}/master)
git %(branch #{branch_name} --track #{user}/master)
end

desc "update", "checkout each branch that has a remote and git pull"
def update
all = branches
current = all.first
last = nil
branches_with_remotes = all.reject { |branch| remote_for_branch(branch) == '' }

branches_with_remotes.reverse.each do |branch|
  git %(checkout #{branch})
  git 'pull -v --no-tags'
  last = branch
end

git %(checkout #{current}) unless last == current

end

desc "create ", "create a new GitHub repository and push to it"
method_options :private => :boolean, :remote => :optional, :branch => :optional
def create(repo_name, opts)
# prompt for username/password
print 'GitHub login ("user:pass"): '
STDIN.gets
auth = $_.chomp
owner = auth.split(':').first

# make a POST request to create a new repo
# WARNING: your GitHub password is being sent unencrypted over HTTP Basic auth
require 'net/http'
uri = URI.parse "http://#{auth}@github.com/repositories"
data = { 'repository[name]' => repo_name, 'repository[public]' => (!opts['private']).to_s }
response = Net::HTTP.post_form(uri, data)
response.error! if response.code >= 400

# set up a new remote and push commits to it
remote = opts['remote'] || 'origin'
branch = opts['branch'] || 'master'
git %(remote add #{remote} git@github.com:#{owner}/#{repo_name}.git), true
puts "added GitHub as remote origin; now pushing commits from #{branch} ..."
git %(push origin #{branch})
# set up tracking
git %(config branch.#{branch}.remote origin)
git %(config branch.#{branch}.merge refs/heads/master)

end

private

def command(com, capture = false)
  unless capture
    system(com)
  else
    %x(#{com}).chomp
  end
end

def git(com, capture = false)
  command('git ' + com, capture)
end

def project_name
  user_and_repo_from(remote_url('origin')).last.chomp('.git')
end

def user_and_repo_from(url)
  case url
  when %r|^git://github\.com/([^/]+/[^/]+)$|: $1.split('/')
  when %r|^(?:ssh://)?(?:git@)?github\.com:([^/]+/[^/]+)$|: $1.split('/')
  end
end

def remote_url(remote)
  git %(config --get remote.#{remote}.url), true
end

def remote_for_branch(name)
  git %(config --get branch.#{name}.remote), true
end

def remotes
  git('remote', true).split("\n")
end

# fetches list of local branches with current being first
def branches
  git('branch', true).split("\n").inject([]) do |all, line|
    unless '*' == line[0, 1]
      all << line.strip
    else
      all.unshift line.sub(/^\*\s+/, '')
    end
  end
end

end
Do you wish to continue [y/N]? N

$ sudo gem install wycats-thor
Password:
Successfully installed wycats-thor-0.11.5
1 gem installed
Installing ri documentation for wycats-thor-0.11.5...
Updating class cache with 4024 classes...
Installing RDoc documentation for wycats-thor-0.11.5...
kristian-mandrups-macbook-pro:thor-tasks kristianconsult$ thor install http://github.com/mislav/thor-tasks/tree/master/github.thor?raw=true
WARNING: unable to load thorfile "/Users/kristianconsult/my_rails/rails3_apps/demos/tasks/thor-tasks/github.thor": /Users/kristianconsult/my_rails/rails3_apps/demos/tasks/thor-tasks/github.thor:76: syntax error, unexpected ':', expecting keyword_then or ',' or ';' or '\n'
when %r|^git://github.com/([^/]+/[^/]+)$|: $1.split('/')
^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.