git-p4-sync 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. data/README.rdoc +7 -1
  2. data/VERSION +1 -1
  3. data/lib/git_p4_sync.rb +29 -2
  4. data/lib/start.rb +4 -0
  5. metadata +27 -9
@@ -23,4 +23,10 @@ The --test switch is useful to test git-p4-sync without actually doing anything
23
23
 
24
24
  == COPYRIGHT
25
25
 
26
- Copyright (c) 2009 {Carl Mercier}[http://carlmercier.com]. See LICENSE for details.
26
+ Copyright (c) 2009-2011 {Carl Mercier}[http://carlmercier.com]. See LICENSE for details.
27
+
28
+ == CONTRIBUTORS
29
+
30
+ {Vincent Batts}[https://github.com/vbatts]
31
+
32
+
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -1,5 +1,5 @@
1
1
  module GitP4Sync
2
-
2
+
3
3
  def run(options)
4
4
  # branch = options[:branch] || "master"
5
5
  branch = "master"
@@ -8,7 +8,17 @@ module GitP4Sync
8
8
  simulate = options[:simulate] || false
9
9
  pull = options[:pull] || false
10
10
  submit = options[:submit] || false
11
- ignore_list = ( options[:ignore] ? options[:ignore].split(",") : [".git"] )
11
+
12
+ @ignore_list = [".git"]
13
+ if options[:ignore]
14
+ if options[:ignore].include?(":")
15
+ @ignore_list = @ignore_list.concat(options[:ignore].split(":"))
16
+ elsif options[:ignore].include?(",")
17
+ @ignore_list = @ignore_list.concat(options[:ignore].split(","))
18
+ else
19
+ @ignore_list = @ignore_list.insert(-1, options[:ignore])
20
+ end
21
+ end
12
22
 
13
23
  git_path = add_slash(File.expand_path(git_path))
14
24
  p4_path = add_slash(File.expand_path(p4_path))
@@ -23,6 +33,10 @@ module GitP4Sync
23
33
  end
24
34
  end
25
35
 
36
+ if File.exist?(gitignore = File.join(git_path, ".gitignore"))
37
+ @ignore_list = @ignore_list.concat(File.read(gitignore).split(/\n/).map {|i| i.gsub("*",".*") } )
38
+ end
39
+
26
40
  diff = diff_dirs(p4_path, git_path)
27
41
 
28
42
  if diff.size > 0
@@ -31,6 +45,7 @@ module GitP4Sync
31
45
  file = strip_leading_slash(d[1])
32
46
 
33
47
  # todo: skip ignored files/directories
48
+ next if is_ignored?(file)
34
49
 
35
50
  puts "#{action.to_s.upcase} in Git: #{file}"
36
51
 
@@ -80,6 +95,18 @@ module GitP4Sync
80
95
  [output, $?]
81
96
  end
82
97
 
98
+ def lambda_ignore(item)
99
+ re = Regexp.compile(/#{item}/)
100
+ lambda {|diff| diff =~ re }
101
+ end
102
+
103
+ def is_ignored?(file)
104
+ @ignore_list.each {|ignore|
105
+ return true if lambda_ignore(ignore).call(file)
106
+ }
107
+ return false
108
+ end
109
+
83
110
  def add_slash(path)
84
111
  path += "/" unless path[-1..-1] == "/"
85
112
  path
@@ -29,6 +29,10 @@ OptionParser.new do |opts|
29
29
  options[:simulate] = o
30
30
  end
31
31
 
32
+ opts.on("-i", "--ignore [STRING]", "Items to ignore. this is a comma delimited list") do |o|
33
+ options[:ignore] = o
34
+ end
35
+
32
36
  end.parse!
33
37
 
34
38
  def error(msg)
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-p4-sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ hash: 25
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 1
10
+ version: 0.1.1
5
11
  platform: ruby
6
12
  authors:
7
13
  - Carl Mercier
@@ -9,19 +15,25 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2009-05-27 00:00:00 -04:00
18
+ date: 2011-02-09 00:00:00 -05:00
13
19
  default_executable: git-p4-sync
14
20
  dependencies:
15
21
  - !ruby/object:Gem::Dependency
16
22
  name: diff_dirs
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
20
26
  requirements:
21
27
  - - ">="
22
28
  - !ruby/object:Gem::Version
29
+ hash: 31
30
+ segments:
31
+ - 0
32
+ - 1
33
+ - 2
23
34
  version: 0.1.2
24
- version:
35
+ type: :runtime
36
+ version_requirements: *id001
25
37
  description: Submit changes made to a Git repository into to Perforce
26
38
  email: carl@carlmercier.com
27
39
  executables:
@@ -52,21 +64,27 @@ rdoc_options:
52
64
  require_paths:
53
65
  - lib
54
66
  required_ruby_version: !ruby/object:Gem::Requirement
67
+ none: false
55
68
  requirements:
56
69
  - - ">="
57
70
  - !ruby/object:Gem::Version
71
+ hash: 3
72
+ segments:
73
+ - 0
58
74
  version: "0"
59
- version:
60
75
  required_rubygems_version: !ruby/object:Gem::Requirement
76
+ none: false
61
77
  requirements:
62
78
  - - ">="
63
79
  - !ruby/object:Gem::Version
80
+ hash: 3
81
+ segments:
82
+ - 0
64
83
  version: "0"
65
- version:
66
84
  requirements: []
67
85
 
68
86
  rubyforge_project: git-p4-sync
69
- rubygems_version: 1.3.2
87
+ rubygems_version: 1.4.2
70
88
  signing_key:
71
89
  specification_version: 3
72
90
  summary: Submit changes made to a Git repository into to Perforce