Module: Git::Multi::Commands
- Defined in:
- lib/git/multi/commands.rb
Class Method Summary collapse
- .archived ⇒ Object
- .check ⇒ Object
- .clone ⇒ Object
- .count ⇒ Object
- .eval(commands) ⇒ Object
- .excess ⇒ Object
- .exec(command, args = []) ⇒ Object
- .find(commands) ⇒ Object
- .forked ⇒ Object
- .help ⇒ Object
- .json ⇒ Object
- .list ⇒ Object
- .missing ⇒ Object
- .paths ⇒ Object
- .private ⇒ Object
- .query(args = []) ⇒ Object
- .raw(args) ⇒ Object
- .refresh ⇒ Object
- .report ⇒ Object
- .spurious ⇒ Object
- .stale ⇒ Object
- .system(args = []) ⇒ Object
- .version ⇒ Object
Class Method Details
.archived ⇒ Object
45 46 47 |
# File 'lib/git/multi/commands.rb', line 45 def archived puts Git::Multi.archived_repositories.map(&:full_name) end |
.check ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/git/multi/commands.rb', line 11 def check Settings.user_status(Git::Multi::USER) Settings.organization_status(Git::Multi::ORGANIZATIONS) Settings.token_status(Git::Multi::TOKEN) Settings.home_status(Git::Multi::HOME) Settings.main_workarea_status(Git::Multi::WORKAREA) Settings.user_workarea_status(Git::Multi::USER) Settings.organization_workarea_status(Git::Multi::ORGANIZATIONS) Settings.file_status(Git::Multi::REPOSITORIES) end |
.clone ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/git/multi/commands.rb', line 99 def clone Git::Multi.missing_repositories.each do |repo| FileUtils.mkdir_p repo.parent_dir repo.just_do_it( ->(project) { notify "Cloning '#{repo.full_name}' repo into #{repo.parent_dir.parent}" Kernel.system "git clone -q #{project.rels[:ssh].href.shellescape}" }, ->(project) { Kernel.system "git clone -q #{project.rels[:ssh].href.shellescape}" }, :in_dir => :parent_dir ) end end |
.count ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/git/multi/commands.rb', line 77 def count # https://developer.github.com/v3/repos/#list-user-repositories user = Git::Multi::USER %w{ all owner member }.each { |type| puts ["#{user}/#{type}", Git::Hub.user_repositories(user, type).count].join("\t") } # https://developer.github.com/v3/repos/#list-organization-repositories for org in Git::Multi::ORGANIZATIONS %w{ all public private forks sources member }.each { |type| puts ["#{org}/#{type}", Git::Hub.org_repositories(org, type).count].join("\t") } end end |
.eval(commands) ⇒ Object
174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/git/multi/commands.rb', line 174 def eval commands Git::Multi.cloned_repositories.each do |repo| Dir.chdir(repo.local_path) do begin repo.instance_eval(commands.join(' ; ')) rescue Octokit::NotFound # project no longer exists on github.com # consider running "git multi --stale"... end end end end |
.excess ⇒ Object
65 66 67 |
# File 'lib/git/multi/commands.rb', line 65 def excess puts Git::Multi.excess_repositories.map(&:full_name) end |
.exec(command, args = []) ⇒ Object
151 152 153 154 |
# File 'lib/git/multi/commands.rb', line 151 def exec command, args = [] args.unshift ['git', '--no-pager', command] system args.flatten end |
.find(commands) ⇒ Object
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/git/multi/commands.rb', line 156 def find commands Git::Multi.cloned_repositories.each do |repo| Dir.chdir(repo.local_path) do begin if repo.instance_eval(commands.join(' && ')) repo.just_do_it( ->(project) { nil ; }, ->(project) { puts project.full_name ; }, ) end rescue Octokit::NotFound # project no longer exists on github.com # consider running "git multi --stale"... end end end end |
.forked ⇒ Object
49 50 51 |
# File 'lib/git/multi/commands.rb', line 49 def forked puts Git::Multi.forked_repositories.map(&:full_name) end |
.help ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/git/multi/commands.rb', line 22 def help # instead of maintaining a list of valid query args in the help- # file, we determine it at runtime... less is more, and all that # TODO remove attributes we 'adorned' the repos with on line 95? query_args = Git::Multi.repositories.sample.fields.sort.each_slice(3).map { |foo, , qux| '%-20s %-20s %-20s' % [foo, , qux] } puts File.read(Git::Multi::MAN_PAGE) % { :version => Git::Multi::VERSION, :query_args => query_args.join("\n "), } end |
.json ⇒ Object
95 96 97 |
# File 'lib/git/multi/commands.rb', line 95 def json puts Git::Multi.repositories.to_json end |
.list ⇒ Object
41 42 43 |
# File 'lib/git/multi/commands.rb', line 41 def list puts Git::Multi.repositories.map(&:full_name) end |
.missing ⇒ Object
61 62 63 |
# File 'lib/git/multi/commands.rb', line 61 def missing puts Git::Multi.missing_repositories.map(&:full_name) end |
.paths ⇒ Object
57 58 59 |
# File 'lib/git/multi/commands.rb', line 57 def paths puts Git::Multi.repositories.map(&:local_path) end |
.private ⇒ Object
53 54 55 |
# File 'lib/git/multi/commands.rb', line 53 def private puts Git::Multi.private_repositories.map(&:full_name) end |
.query(args = []) ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/git/multi/commands.rb', line 115 def query args = [] Git::Multi.repositories.each do |repo| repo.just_do_it( ->(project) { args.each do |attribute| puts "#{attribute}: #{project[attribute]}" end }, ->(project) { print "#{project.full_name}: " puts args.map { |attribute| project[attribute] }.join(' ') }, ) end end |
.raw(args) ⇒ Object
146 147 148 149 |
# File 'lib/git/multi/commands.rb', line 146 def raw args args.unshift ['sh', '-c'] system args.flatten end |
.refresh ⇒ Object
91 92 93 |
# File 'lib/git/multi/commands.rb', line 91 def refresh Git::Multi.refresh_repositories end |
.report ⇒ Object
35 36 37 38 39 |
# File 'lib/git/multi/commands.rb', line 35 def report if (missing_repos = Git::Multi::missing_repositories).any? notify(missing_repos.map(&:full_name), :subtitle => "#{missing_repos.count} missing repos") end end |
.spurious ⇒ Object
73 74 75 |
# File 'lib/git/multi/commands.rb', line 73 def spurious puts Git::Multi.spurious_repositories.map(&:full_name) end |
.stale ⇒ Object
69 70 71 |
# File 'lib/git/multi/commands.rb', line 69 def stale puts Git::Multi.stale_repositories.map(&:full_name) end |
.system(args = []) ⇒ Object
131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/git/multi/commands.rb', line 131 def system args = [] args.map!(&:shellescape) Git::Multi.cloned_repositories.each do |repo| repo.just_do_it( ->(project) { Kernel.system "#{args.join(' ')}" }, ->(project) { Kernel.system "#{args.join(' ')} 2>&1 | sed -e 's#^##{project.full_name.shellescape}: #'" }, :in_dir => :local_path ) end end |
.version ⇒ Object
7 8 9 |
# File 'lib/git/multi/commands.rb', line 7 def version puts Git::Multi::LONG_VERSION end |