git - Parsing file names using ruby Net::SSH -


working on automating task job.

issue: have rather large stack of git repos hosted on private git server @ our main office. work @ remote location.

goal: need clone many (50+) repos without authenticating , manually typing out filename ever time.

this supposed quick , dirty version written in ruby (i'm learning ruby i'm trying use , needs it's for) can use template more fine tuned git operations in future.

this have right now:

#!/usr/bin/ruby  require 'net/ssh'  git_server_address = "x.x.x.x" git_server_login = "username" puts "enter password #{git_server_login}" git_server_passwd = gets.chomp $gitnames = []   def getgitnames(address, login, passwd)   net::ssh.start(address, login, password: passwd) |ssh|     ssh.exec!("cd /git")     ssh.exec!("find . -type d -exec echo '{}' \\;") |file|       $gitnames.push(file)     end   end end  $gitnames = getgitnames(git_server_address, git_server_login, git_server_passwd) $gitnames.each |file|   if file.equal?('slamros.git')     puts(file)     #puts system("git clone #{git_server_login}@#{git_server_address}:/git/#    {file}")     #puts git_server_passwd   end end 

if abhorrently ugly, apologize, i'm still new @ job , professional programming. know there best practices i'm not following goal operational eod.

essentially i'm trying use ssh.exec! , find -exec names of files in /git folder.

once working use filenames have pull git clones on own system. have these lines commented out.

my code asks password, processes 5 seconds, , gives me error:

/gitclone.rb:21:in `<top (required)>': undefined method `each' nil:nilclass (nomethoderror) -e:1:in `load' -e:1:in `<main>' 

i i'm doing in getgitnames() method wrong, appreciate in pointing out or ideas of other ways accomplish task ruby.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -