Module: Git::Multi
- Defined in:
- lib/git/multi.rb,
lib/git/multi/version.rb,
lib/git/multi/commands.rb,
lib/git/multi/settings.rb
Defined Under Namespace
Modules: Commands, Nike, Settings
Constant Summary
collapse
- HOME =
Dir.home
- DEFAULT_WORKAREA =
File.join(HOME, 'Workarea')
- WORKAREA =
git_option('git.multi.workarea', DEFAULT_WORKAREA)
- DEFAULT_TOKEN =
env_var('OCTOKIT_ACCESS_TOKEN')
- TOKEN =
git_option('github.token', DEFAULT_TOKEN)
- CACHE =
File.join(HOME, '.git', 'multi')
- REPOSITORIES =
File.join(CACHE, 'repositories.byte')
- USER =
git_option('github.user')
- ORGANIZATIONS =
git_option('github.organizations').split(/\s*,\s*/)
- MAN_PAGE =
File.expand_path('../../doc/git-multi.man', __dir__)
- NAME =
'git-multi'
- VERSION =
'1.0.2'
- LONG_VERSION =
"%s v%s (%s v%s, %s v%s, %s v%s)" % [
NAME,
VERSION,
'octokit.rb',
Octokit::VERSION,
'sawyer',
Sawyer::VERSION,
'psych',
Psych::VERSION,
]
- PIM =
<<~"EOPIM" # gem post_install_message
The required settings for \033[1mgit multi\33[0m are as follows:
\tgit config --global --add \033[1mgithub.user\033[0m <your_github_username>
\tgit config --global --add \033[1mgithub.organizations\033[0m <your_github_orgs>
\tgit config --global --add \033[1mgithub.token\033[0m <your_github_oauth_token>
Unless your top-level workarea is `${HOME}/Workarea` you should also set:
\tgit config --global --add \033[1mgit.multi.workarea\033[0m <your_root_workarea>
Thanks for using \033[1mgit multi\033[0m ... the ultimate multi-repo
Class Method Summary
collapse
Class Method Details
.archived_repositories ⇒ Object
lists of repositories with a given state
137
138
139
|
# File 'lib/git/multi.rb', line 137
def archived_repositories
repositories.find_all(&:archived)
end
|
.cloned_repositories ⇒ Object
186
187
188
189
190
|
# File 'lib/git/multi.rb', line 186
def cloned_repositories
repositories.find_all { |project|
File.directory? project.local_path
}
end
|
.excess_repositories ⇒ Object
derived lists of repositories
153
154
155
156
157
158
|
# File 'lib/git/multi.rb', line 153
def excess_repositories
repository_full_names = repositories.map(&:full_name)
local_repositories.reject { |project|
repository_full_names.include? project.full_name
}
end
|
.forked_repositories ⇒ Object
141
142
143
|
# File 'lib/git/multi.rb', line 141
def forked_repositories
repositories.find_all(&:fork)
end
|
.github_repositories ⇒ Object
remote repositories (on GitHub)
.local_repositories ⇒ Object
56
57
58
59
60
61
|
# File 'lib/git/multi.rb', line 56
def local_repositories
(
@local_user_repositories[USER] +
ORGANIZATIONS.map { |org| @local_org_repositories[org] }
).flatten
end
|
.missing_repositories ⇒ Object
180
181
182
183
184
|
# File 'lib/git/multi.rb', line 180
def missing_repositories
repositories.find_all { |project|
!File.directory? project.local_path
}
end
|
.private_repositories ⇒ Object
145
146
147
|
# File 'lib/git/multi.rb', line 145
def private_repositories
repositories.find_all(&:private)
end
|
.refresh_repositories ⇒ Object
74
75
76
77
78
79
80
|
# File 'lib/git/multi.rb', line 74
def refresh_repositories
File.directory?(CACHE) || FileUtils.mkdir_p(CACHE)
File.open(REPOSITORIES, 'wb') do |file|
Marshal.dump(github_repositories, file)
end
end
|
.repositories ⇒ Object
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
# File 'lib/git/multi.rb', line 109
def repositories
if File.size?(REPOSITORIES)
@repositories ||= Marshal.load(File.read(REPOSITORIES)).tap do |projects|
notify "Finished loading #{REPOSITORIES}"
projects.each_with_index do |project, index|
project.client = Git::Hub.send(:client)
project.parent_dir = Pathname.new(File.join(WORKAREA, project.owner.login))
project.local_path = Pathname.new(File.join(WORKAREA, project.full_name))
project.fractional_index = "#{index + 1}/#{projects.count}"
project.compliant_ssh_url = 'ssh://%s/%s' % project.ssh_url.split(':', 2)
project.abbreviated_ssh_url = project.ssh_url.chomp('.git')
project.extend Nike
end
end
else
refresh_repositories and repositories
end
end
|
.spurious_repositories ⇒ Object
167
168
169
170
171
172
173
174
175
176
177
178
|
# File 'lib/git/multi.rb', line 167
def spurious_repositories
cloned_repositories.find_all { |project|
origin_url = `git -C #{project.local_path} config --get remote.origin.url`.chomp
![
project.clone_url,
project.ssh_url,
project.compliant_ssh_url,
project.abbreviated_ssh_url,
project.git_url,
].include? origin_url
}
end
|
.stale_repositories ⇒ Object
160
161
162
163
164
165
|
# File 'lib/git/multi.rb', line 160
def stale_repositories
repository_full_names = github_repositories.map(&:full_name)
repositories.reject { |project|
repository_full_names.include? project.full_name
}
end
|