Method: Organizations#assignment_repository

Defined in:
lib/actions/orgs.rb

#assignment_repository(client, config, name) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/actions/orgs.rb', line 48

def assignment_repository(client,config,name)
  ex=false
  until ex==true
    puts "\n"
    puts "Assignment: #{name}"
    puts "1) Add a repository already created "
    puts "2) Create a new empty repository"
    puts "3) Don't assign a repository yet"
    print "option => "
    op=gets.chomp
    puts "\n"
    if op=="3" or op=="1" or op=="2"
      ex=true
    end
  end
  case
  when op=="1" || op=="2"

    if op=="1"
      ex2=false
      until ex2==true
        exname=false
        until exname==true
          puts "Name of the repository -> Owner/Repository or Organization/Repository :"
          reponame=gets.chomp
          if reponame.split("/").size!=2 and reponame!=""
            puts "Please introduce a valid format."
          else
            exname=true
          end
          if reponame==""
            exname=true
            ex2=true
          end
        end
        if reponame!=""
          if client.repository?("#{reponame}")==false
            puts "The repository #{reponame} doesn't exist\n"
            puts "\nName of the repository (To skip and add the repository later, only press enter): "
            if reponame==""
              ex2=true
            end
          else
            ex2=true
          end
        end
      end
    end
    if op=="2"
      ex2=false
      until ex2==true
        ex2=Repositories.new().create_repository(client,config,reponame,false,ORGS)
        if ex2==false
          puts "Name of the repository (To skip and add the repository later, press enter): "
          reponame=gets.chomp
          if reponame==""
            ex2=true
          end
        end
      end
    end
  when op=="3" then reponame=""
  end
  return reponame
end