basketcase 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Binary file
@@ -1,3 +1,8 @@
1
+ === 1.1.0 / 2008-09-17
2
+
3
+ * Add 'bc-mirror' script, to support periodically publishing an
4
+ externally-managed directory into ClearCase.
5
+
1
6
  === 1.0.0 / 2008-09-16
2
7
 
3
8
  * Converted into a gem, using sow.
@@ -3,4 +3,5 @@ Manifest.txt
3
3
  README.txt
4
4
  Rakefile
5
5
  bin/basketcase
6
+ bin/bc-mirror
6
7
  lib/basketcase.rb
data/README.txt CHANGED
@@ -1,5 +1,11 @@
1
1
  = basketcase
2
2
 
3
+ * http://basketcase.rubyforge.org/
4
+ * http://rubyforge.org/projects/basketcase/
5
+ * http://dogbiscuit.org/mdub/
6
+
7
+ == Description
8
+
3
9
  BasketCase is a (Ruby) script that encapsulates the Rational ClearCase
4
10
  command-line interface, <code>cleartool</code>, making it (slightly) more
5
11
  comfortable for developers more used to non-locking version-control systems
@@ -77,11 +83,6 @@ way:
77
83
 
78
84
  Mike wrote BasketCase in frustration.
79
85
 
80
- == See also
81
-
82
- * http://rubyforge.org/projects/basketcase/
83
- * http://dogbiscuit.org/mdub/
84
-
85
86
  == License
86
87
 
87
88
  (The MIT License)
@@ -0,0 +1,127 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ # Synchronise a directory with a Clearcase snapshot view.
4
+ #
5
+ # @author Mike Williams
6
+
7
+ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
8
+
9
+ require 'basketcase'
10
+ require 'pathname'
11
+ require 'ftools'
12
+
13
+ class DirSyncer
14
+
15
+ def initialize(src_root, dest_root)
16
+ @src_root = Pathname(src_root)
17
+ @dest_root = Pathname(dest_root)
18
+ end
19
+
20
+ def sync
21
+ visit(@src_root)
22
+ cleanup(@dest_root)
23
+ end
24
+
25
+ private
26
+
27
+ def ignored?(path)
28
+ path.to_str =~ %r{(^|/).git($|/)}
29
+ end
30
+
31
+ def visit(src_file)
32
+ return if ignored?(src_file)
33
+ if src_file.directory?
34
+ sync_dir(src_file)
35
+ else
36
+ sync_file(src_file)
37
+ end
38
+ end
39
+
40
+ def ensure_we_can_write_to(file)
41
+ file.chmod(file.stat.mode | 0600) unless file.writable?
42
+ end
43
+
44
+ def sync_dir(src_dir)
45
+ src_dir.children.sort.each do |f|
46
+ visit(f)
47
+ end
48
+ end
49
+
50
+ def sync_file(src_file)
51
+ file_path = src_file.relative_path_from(@src_root)
52
+ dest_file = @dest_root + file_path
53
+ dest_file.parent.mkpath
54
+ ensure_we_can_write_to(dest_file.parent)
55
+ if dest_file.exist?
56
+ if File.read(src_file) == File.read(dest_file)
57
+ return
58
+ end
59
+ ensure_we_can_write_to(dest_file)
60
+ end
61
+ puts file_path
62
+ FileUtils.copy(src_file, dest_file)
63
+ end
64
+
65
+ def cleanup(dest_file)
66
+ if dest_file.directory?
67
+ cleanup_dir(dest_file)
68
+ else
69
+ cleanup_file(dest_file)
70
+ end
71
+ end
72
+
73
+ def cleanup_dir(dest_dir)
74
+ dest_dir.children.sort.each do |f|
75
+ cleanup(f)
76
+ end
77
+ if dest_dir.children.empty?
78
+ puts "rmdir #{dest_dir.relative_path_from(@dest_root)}"
79
+ dest_dir.rmdir
80
+ end
81
+ end
82
+
83
+ def cleanup_file(dest_file)
84
+ file_path = dest_file.relative_path_from(@dest_root)
85
+ src_file = @src_root + file_path
86
+ if !src_file.exist? || ignored?(file_path)
87
+ ensure_we_can_write_to(dest_file.parent)
88
+ puts "rm #{file_path}"
89
+ dest_file.delete
90
+ end
91
+ end
92
+
93
+ end
94
+
95
+ #---( Mainline )---
96
+
97
+ def exit_with(status, message)
98
+ $stderr.puts message; exit(status)
99
+ end
100
+
101
+ exit_with(3, "usage: #{File.basename($0)} <source> <clearcase_snapshot>") unless ARGV.size == 2
102
+
103
+ source_dir, cc_snapshot_dir = ARGV
104
+ source_dir = Pathname(source_dir).expand_path
105
+ cc_snapshot_dir = Pathname(cc_snapshot_dir).expand_path
106
+
107
+ def check_dir(dir)
108
+ exit_with(5, "ERROR: no such directory? #{dir}") unless dir.exist?
109
+ exit_with(5, "ERROR: #{dir} is not a directory") unless dir.directory?
110
+ end
111
+
112
+ check_dir(source_dir)
113
+ check_dir(cc_snapshot_dir)
114
+
115
+ puts "--- Syncing to CC view"
116
+ DirSyncer.new(source_dir, cc_snapshot_dir).sync
117
+
118
+ Dir.chdir(cc_snapshot_dir)
119
+ basketcase = Basketcase.new
120
+
121
+ puts "--- Adding/removing stuff"
122
+ basketcase.do('auto-sync', '-n')
123
+
124
+ puts "--- Commiting"
125
+ basketcase.do('auto-commit', '-m', "upload from #{source_dir}")
126
+
127
+ puts "--- Done"
@@ -3,7 +3,7 @@ require 'forwardable'
3
3
 
4
4
  class Basketcase
5
5
 
6
- VERSION = '1.0.0'
6
+ VERSION = '1.1.0'
7
7
 
8
8
  @usage = <<EOF
9
9
  usage: basketcase <command> [<options>]
metadata CHANGED
@@ -1,15 +1,36 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: basketcase
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - mdub
8
8
  autorequire:
9
9
  bindir: bin
10
- cert_chain: []
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDNDCCAhygAwIBAgIBADANBgkqhkiG9w0BAQUFADBAMQ0wCwYDVQQDDARtZHVi
14
+ MRowGAYKCZImiZPyLGQBGRYKZG9nYmlzY3VpdDETMBEGCgmSJomT8ixkARkWA29y
15
+ ZzAeFw0wODEwMTgxOTEyMjFaFw0wOTEwMTgxOTEyMjFaMEAxDTALBgNVBAMMBG1k
16
+ dWIxGjAYBgoJkiaJk/IsZAEZFgpkb2diaXNjdWl0MRMwEQYKCZImiZPyLGQBGRYD
17
+ b3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuN6ECjnDnRrS8+e/
18
+ Ld0qOFQm7pLwSbyqHr0ZFRTZybDUTOw1IHpaKUzEcblOfAI6QhdqiRAhd0/SGHhV
19
+ kLky24wpdI1mpvdYNB7EUQKp0xlDKD4H2zpI7aOpcaWQD2vtkx2QcaOqzwd7WDHz
20
+ PqgylAv6RCHFhbUOjDcwkaxce0VYwnCxtAn7UaxdOUoXvMwptKUp9Kn9AxFNklYU
21
+ 4m29nz9n8o1Yat1wSen+eUM6HRbazeK5jiMUIC9lygvdibfxAVeGtQwk3g18WmR8
22
+ gbROV9ZPCwbIQyxoMvY2ZBTVfAxf6pEYiwr33HlgdTKUHdymJ9FGuRINF5L/Q3DI
23
+ mDltTwIDAQABozkwNzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU
24
+ BSFEL+Pfdvqb0bjyd7t4x1++/NgwDQYJKoZIhvcNAQEFBQADggEBAHM3UqaW13Os
25
+ Q1ME0sLhHFvF4QE7Z6mRmWUwaokJgSLQdy+YDC069AJPBDiSBmg3oJtzVTTrGadV
26
+ bguWLRGZwjHEBSWGSnJlIoz3jKgVBcYEYhe+snrLYOr0BoF1U64WiVPPEGDdHlbM
27
+ /tcBD2oDTz7mt52yHGJArq3bceD8UE5ZRZ4GMO5X+oQlSDkI395dcgAgCWhvzppa
28
+ 7tmPDgdNhjWsIS5Ozf1hu4VguwOXYMX2Gez4B3Al/2Jn+2vzSCsmd3RRHUq9RBx5
29
+ +pTb3lixdToGe6TKuoxCURlQWS5JYyXm8TRVmaZrJcaNKN6bmlLNTfPWv3rMqbTz
30
+ oYjap0xxejs=
31
+ -----END CERTIFICATE-----
11
32
 
12
- date: 2008-10-15 00:00:00 +11:00
33
+ date: 2008-10-19 00:00:00 +11:00
13
34
  default_executable:
14
35
  dependencies:
15
36
  - !ruby/object:Gem::Dependency
@@ -22,11 +43,12 @@ dependencies:
22
43
  - !ruby/object:Gem::Version
23
44
  version: 1.7.0
24
45
  version:
25
- description: ""
46
+ description: BasketCase is a (Ruby) script that encapsulates the Rational ClearCase command-line interface, <code>cleartool</code>, making it (slightly) more comfortable for developers more used to non-locking version-control systems such as CVS or Subversion.
26
47
  email:
27
48
  - mdub@dogbiscuit.org
28
49
  executables:
29
50
  - basketcase
51
+ - bc-mirror
30
52
  extensions: []
31
53
 
32
54
  extra_rdoc_files:
@@ -39,9 +61,10 @@ files:
39
61
  - README.txt
40
62
  - Rakefile
41
63
  - bin/basketcase
64
+ - bin/bc-mirror
42
65
  - lib/basketcase.rb
43
66
  has_rdoc: true
44
- homepage: BasketCase is a (Ruby) script that encapsulates the Rational ClearCase
67
+ homepage: http://basketcase.rubyforge.org/
45
68
  post_install_message:
46
69
  rdoc_options:
47
70
  - --main
@@ -66,6 +89,6 @@ rubyforge_project: basketcase
66
89
  rubygems_version: 1.2.0
67
90
  signing_key:
68
91
  specification_version: 2
69
- summary: ""
92
+ summary: BasketCase is a (Ruby) script that encapsulates the Rational ClearCase command-line interface, <code>cleartool</code>, making it (slightly) more comfortable for developers more used to non-locking version-control systems such as CVS or Subversion.
70
93
  test_files: []
71
94
 
@@ -0,0 +1,3 @@
1
+ �t�7�A�����oa�M�u�O����'p4K
2
+ �a�|���ps�&R� ��9�;���)96�{Æ�G���3��7��M��x�M �����Ac��Nԧ��G� .���4�@�(Rʹ�.�rfݿ��#�>���|A%���^�[Spsj�%S��C2t�e�Hq�J� ��zB0�D�M Wb1�u�d��Ln�*2� ӆ������8�ے?M9�
3
+ &�M̓F������Əe