git-projects 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 34f4abc5e7f5fa48ca900a73ff2be6139f090f92
4
- data.tar.gz: db54c8e627eaa582235050ced39c2ef7dfa69c8c
3
+ metadata.gz: b0d3460f9fc31b8d0e3f12f125d3fe7a3f6f1ea5
4
+ data.tar.gz: 0a20d5d089c2013fb1ec5d7c50e8fadf36fa9535
5
5
  SHA512:
6
- metadata.gz: b4aa798d4c5d977b4b64844affaf33c3b624ddfb5903e05ab90cad497dec9a79f1b3eaa7771262454b3d3c4f9fe189b95b0d1a09c1c4e8559355fb85440e0bbc
7
- data.tar.gz: ebe44e88e248b46f1314f6945ed5f180ef836c4d676a900bad4bb7ba85f00ee347d4ccc18e40224be2d8f82e3e54f055904dc11548b4ce57c8f5552390bd0a05
6
+ metadata.gz: bb218234f1e950915c16546e4cb9d5bbb8f0eb4bce0ecfa34477295347662a982e0538b1fbaf9b124c002b69b547df6b7e1cb48678d8923cf4ca1d5fc4844267
7
+ data.tar.gz: 8225526d267a0544ee86e0355652b71730c9a6d2d6d4e4416199c5fea9ff1e48654022e62b56304cd71aa82d8d35fa242611a59c111fcab1e8462b508ea73ae4
data/lib/git-projects.rb CHANGED
File without changes
@@ -1,3 +1,3 @@
1
1
  module GitProjects
2
- VERSION = '1.0.2'
2
+ VERSION = '1.0.3'
3
3
  end
@@ -64,11 +64,10 @@ class GitProject
64
64
  # 2. Add all other remotes unless it is origin
65
65
  def create_project_and_remotes(k, v)
66
66
  puts "root_dir isn't defined for #{k}" unless v['root_dir']
67
- unless File.directory?(v['root_dir'])
68
- puts "The dir #{v['root_dir']} does not exist"
69
- end
70
- GitProject.create_root_dir(v['root_dir'])
71
- g = GitProject.clone(v.values[0], k, v['root_dir'])
67
+ GitProject.dir_or_symlink_exist?(v['root_dir'])
68
+ root_dir = GitProject.real_root_dir(v['root_dir'])
69
+ GitProject.create_root_dir(root_dir)
70
+ g = GitProject.clone(v.values[0], k, root_dir)
72
71
  GitProject.add_remote(g, v) if g
73
72
  end
74
73
 
@@ -76,8 +75,9 @@ class GitProject
76
75
  def fetch_all(group = nil)
77
76
  @project.all(group).each do |k, v|
78
77
  puts "Fetching changes for #{k}".green
79
- GitProject.create_root_dir(v['root_dir'])
80
- working_dir = "#{v['root_dir']}/#{k}"
78
+ root_dir = GitProject.real_root_dir(v['root_dir'])
79
+ GitProject.create_root_dir(root_dir)
80
+ working_dir = "#{root_dir}/#{k}"
81
81
  g = Git.open(working_dir) || Git.init(working_dir)
82
82
  GitProject.fetch(g)
83
83
  end
@@ -23,13 +23,11 @@ module GitProjectConfig
23
23
 
24
24
  # Check for the config
25
25
  def check_config
26
- if ENV['GIT_PROJECTS']
27
- puts "Checking repositories. If things go wrong,
26
+ puts "Checking repositories. If things go wrong,
28
27
  update #{ENV['GIT_PROJECTS']}".green
29
- else
30
- fail "Please add the path your git projects config. \n
31
- export GIT_PROJECTS=/path/to/git_projects.yml"
32
- end
28
+
29
+ fail "Please add the path your git projects config. \n
30
+ export GIT_PROJECTS=/path/to/git_projects.yml" unless ENV['GIT_PROJECTS']
33
31
  end
34
32
 
35
33
  # Create YAML file
@@ -6,14 +6,29 @@ module GitProjectRemote
6
6
 
7
7
  # Check/ add new remotes
8
8
  module ClassMethods
9
+ # Check if symbolic link or directory exists
10
+ def dir_or_symlink_exist?(path)
11
+ symbolic_link_exists = (File.symlink?(path) && File.readlink(path))
12
+ unless File.directory?(path) || symbolic_link_exists
13
+ puts "The dir #{path} does not exist"
14
+ end
15
+ end
16
+
17
+ # Get real root_dir
18
+ def real_root_dir(path)
19
+ return File.readlink(path) if File.symlink?(path)
20
+ path
21
+ end
22
+
9
23
  # Clone unless dir exists
10
24
  def clone(url, name, path)
25
+ path = real_root_dir(path)
11
26
  r = "#{path}/#{name}"
12
- if Git.open(r)
27
+ g = Git.open(r)
28
+ if g
13
29
  puts 'Already cloned '.yellow + "#{url}".blue
14
30
  else
15
31
  Git.clone(url, name, path: path) || Git.init(r)
16
- g = Git.open(r)
17
32
  puts "Cloning #{url} as #{name} into #{path}".green
18
33
  end
19
34
  g
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-projects
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
- - Katherine Pe
7
+ - Katherine G. Pe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-14 00:00:00.000000000 Z
11
+ date: 2015-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize