update_gitrepos 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/README.md +36 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/bin/update_gitrepos +5 -0
- data/lib/update_gitrepos.rb +71 -0
- data/lib/update_gitrepos/version.rb +3 -0
- data/update_gitrepos.gemspec +34 -0
- metadata +84 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 48c6158e8830f9889b7278d178dc8990639f649b
|
4
|
+
data.tar.gz: 94aa969d960675d2890dd6d9f1441ae822e9db08
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 991bf2173fba8ea937bdf8915648f8bca4d92a222c3b527889488f6d9a1f7bc31d30eda1334c6fbf7f93c364a23a59557d525ae2dc8a784ff7258ff1e7e23b0b
|
7
|
+
data.tar.gz: 60c11bcbfbf8531aa663b22b3429907ace17437447fd8451a39ef3c19f09b1968547a6390d950b38191ed54c8bc1f10e8afeff096baa887ac1c8f9d6ca852bda
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at yhlssdone@gmail.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# UpdateGitrepos
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/update_gitrepos`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'update_gitrepos'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install update_gitrepos
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/HongliYu/update_gitrepos. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "update_gitrepos"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/bin/update_gitrepos
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
require "update_gitrepos/version"
|
2
|
+
|
3
|
+
# Utils
|
4
|
+
class Array
|
5
|
+
def prog_each(&block)
|
6
|
+
bar_length = (`tput cols` || 80).to_i - 30
|
7
|
+
time_now = Time.now
|
8
|
+
total = self.count
|
9
|
+
last_flush = 0
|
10
|
+
flush_time = 1
|
11
|
+
self.each_with_index{|element, x|
|
12
|
+
cur = (x + 1) * 100 / total
|
13
|
+
time_left = (((Time.now - time_now) * (100 - cur)).to_f / cur).ceil
|
14
|
+
if (Time.now - last_flush).to_i >= flush_time or time_left < 1
|
15
|
+
time_left_graceful = Time.at(time_left).utc.strftime("%H:%M:%S")
|
16
|
+
if time_left > 86400
|
17
|
+
time_left_graceful = res.split(":")
|
18
|
+
time_left_graceful[0] = (time_left_graceful[0].to_i + days * 24).to_s
|
19
|
+
time_left_graceful = time_left_graceful.join(":")
|
20
|
+
end
|
21
|
+
print "\r"
|
22
|
+
cur_len = (bar_length * (x + 1)) / total
|
23
|
+
print "[" << (["#"] * cur_len).join << (["-"] * (bar_length - cur_len)).join << "] #{cur}% [#{time_left_graceful} left]"
|
24
|
+
last_flush = Time.now
|
25
|
+
end
|
26
|
+
block.call element if block
|
27
|
+
}
|
28
|
+
puts "\n"
|
29
|
+
"Done."
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# TODO:文件目录校验 .git,遍历目录下所有的.git库全部更新
|
34
|
+
def traverse(filePath)
|
35
|
+
gitReposArray = Array.new
|
36
|
+
if File.directory?(filePath)
|
37
|
+
Dir.foreach(filePath) do |fileName|
|
38
|
+
if File.directory?(filePath + "/" + fileName) and fileName != "." and fileName != ".."
|
39
|
+
gitReposArray << (filePath + "/" + fileName)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
else
|
43
|
+
puts "Files:" + filePath
|
44
|
+
end
|
45
|
+
return gitReposArray
|
46
|
+
end
|
47
|
+
|
48
|
+
def updateRepos(gitReposArray)
|
49
|
+
gitReposArray.prog_each {
|
50
|
+
|repoPath|
|
51
|
+
system("echo \n" )
|
52
|
+
system("echo Begin update git repo:#{repoPath} \n cd #{repoPath} \n git pull")
|
53
|
+
}
|
54
|
+
end
|
55
|
+
|
56
|
+
# Main
|
57
|
+
module UpdateGitrepos
|
58
|
+
def self.run(filePath)
|
59
|
+
puts "running..."
|
60
|
+
if filePath.nil? || filePath.empty?
|
61
|
+
puts "error: need git repos directory path"
|
62
|
+
else
|
63
|
+
if File.directory?(filePath)
|
64
|
+
gitReposArray = traverse(filePath)
|
65
|
+
updateRepos(gitReposArray)
|
66
|
+
else
|
67
|
+
puts "error: not a directory"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'update_gitrepos/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "update_gitrepos"
|
8
|
+
spec.version = UpdateGitrepos::VERSION
|
9
|
+
spec.authors = ["HongliYu"]
|
10
|
+
spec.email = ["yhlssdone@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{update all git repos at once.}
|
13
|
+
spec.description = %q{update all git repos at once.}
|
14
|
+
spec.homepage = "https://github.com/HongliYu/update_gitrepos"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
19
|
+
# if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
# else
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
# end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
# spec.bindir = "exe"
|
27
|
+
# spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.executables = ["update_gitrepos"]
|
29
|
+
spec.require_paths = ["lib"]
|
30
|
+
spec.required_ruby_version = '>= 2.0.0'
|
31
|
+
|
32
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
33
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: update_gitrepos
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- HongliYu
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: update all git repos at once.
|
42
|
+
email:
|
43
|
+
- yhlssdone@gmail.com
|
44
|
+
executables:
|
45
|
+
- update_gitrepos
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- CODE_OF_CONDUCT.md
|
51
|
+
- Gemfile
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- bin/console
|
55
|
+
- bin/setup
|
56
|
+
- bin/update_gitrepos
|
57
|
+
- lib/update_gitrepos.rb
|
58
|
+
- lib/update_gitrepos/version.rb
|
59
|
+
- update_gitrepos.gemspec
|
60
|
+
homepage: https://github.com/HongliYu/update_gitrepos
|
61
|
+
licenses:
|
62
|
+
- MIT
|
63
|
+
metadata: {}
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 2.0.0
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 2.6.1
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: update all git repos at once.
|
84
|
+
test_files: []
|