braid 0.7.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +4 -1
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +7 -0
  5. data/CONTRIBUTING.md +26 -0
  6. data/Gemfile +1 -2
  7. data/LICENSE +3 -1
  8. data/README.md +90 -51
  9. data/Rakefile +6 -14
  10. data/bin/braid +9 -37
  11. data/braid.gemspec +11 -11
  12. data/lib/braid.rb +13 -12
  13. data/lib/braid/command.rb +9 -42
  14. data/lib/braid/commands/add.rb +6 -8
  15. data/lib/braid/commands/list.rb +11 -6
  16. data/lib/braid/commands/push.rb +5 -5
  17. data/lib/braid/commands/remove.rb +1 -3
  18. data/lib/braid/commands/setup.rb +4 -8
  19. data/lib/braid/commands/update.rb +12 -14
  20. data/lib/braid/config.rb +38 -43
  21. data/lib/braid/mirror.rb +19 -63
  22. data/lib/braid/operations.rb +51 -90
  23. data/lib/braid/version.rb +1 -1
  24. data/{test/config_test.rb → spec/config_spec.rb} +14 -17
  25. data/{test → spec}/fixtures/shiny/README +0 -0
  26. data/{test → spec}/fixtures/skit1.1/layouts/layout.liquid +0 -0
  27. data/{test → spec}/fixtures/skit1.2/layouts/layout.liquid +0 -0
  28. data/{test → spec}/fixtures/skit1/layouts/layout.liquid +0 -0
  29. data/{test → spec}/fixtures/skit1/preview.png +0 -0
  30. data/spec/integration/adding_spec.rb +43 -0
  31. data/{test/integration/updating_test.rb → spec/integration/updating_spec.rb} +2 -41
  32. data/spec/integration_helper.rb +47 -0
  33. data/{test/mirror_test.rb → spec/mirror_spec.rb} +6 -33
  34. data/{test/operations_test.rb → spec/operations_spec.rb} +2 -2
  35. data/{test → spec}/test_helper.rb +6 -2
  36. metadata +86 -123
  37. data/lib/core_ext.rb +0 -13
  38. data/test/braid_test.rb +0 -7
  39. data/test/integration/adding_test.rb +0 -80
  40. data/test/integration_helper.rb +0 -70
data/lib/core_ext.rb DELETED
@@ -1,13 +0,0 @@
1
- require 'yaml'
2
-
3
- class Hash
4
- def to_yaml(opts = {})
5
- YAML::quick_emit(object_id, opts) do |out|
6
- out.map(taguri, to_yaml_style) do |map|
7
- sort.each do |k, v|
8
- map.add(k, v)
9
- end
10
- end
11
- end
12
- end
13
- end
data/test/braid_test.rb DELETED
@@ -1,7 +0,0 @@
1
- require File.dirname(__FILE__) + '/test_helper'
2
-
3
- describe "Braid" do
4
- it "puts the lotion in the basket" do
5
- # dedicated to dblack
6
- end
7
- end
@@ -1,80 +0,0 @@
1
- require File.dirname(__FILE__) + '/../integration_helper'
2
-
3
- describe "Adding a mirror in a clean repository" do
4
-
5
- before do
6
- FileUtils.rm_rf(TMP_PATH)
7
- FileUtils.mkdir_p(TMP_PATH)
8
- end
9
-
10
- describe "from a git repository" do
11
- before do
12
- @shiny = create_git_repo_from_fixture("shiny")
13
- @skit1 = create_git_repo_from_fixture("skit1")
14
- end
15
-
16
- it "should add the files and commit" do
17
- in_dir(@shiny) do
18
- `#{BRAID_BIN} add --type git #{@skit1}`
19
- end
20
-
21
- file_name = "skit1/layouts/layout.liquid"
22
- output = `diff -U 3 #{File.join(FIXTURE_PATH, file_name)} #{File.join(TMP_PATH, "shiny", file_name)}`
23
- $?.should.be.success
24
-
25
- output = `git log --pretty=oneline`.split("\n")
26
- output.length.should == 2
27
- output[0].should =~ /Braid: Add mirror 'skit1' at '[0-9a-f]{7}'/
28
- end
29
-
30
- it "should create .braids and add the mirror to it" do
31
- in_dir(@shiny) do
32
- `#{BRAID_BIN} add --type git #{@skit1}`
33
- end
34
-
35
- braids = YAML::load_file("#{@shiny}/.braids")
36
- braids["skit1"]["squashed"].should == true
37
- braids["skit1"]["url"].should == @skit1
38
- braids["skit1"]["type"].should == "git"
39
- braids["skit1"]["revision"].should.not.be nil
40
- braids["skit1"]["branch"].should == "master"
41
- braids["skit1"]["remote"].should == "braid/skit1"
42
- end
43
- end
44
-
45
- describe "from an svn repository" do
46
- before do
47
- @shiny = create_git_repo_from_fixture("shiny")
48
- @skit1 = create_svn_repo_from_fixture("skit1")
49
- end
50
-
51
- it "should add the files and commit" do
52
- in_dir(@shiny) do
53
- `#{BRAID_BIN} add --type svn #{@skit1}`
54
- end
55
-
56
- file_name = "skit1/layouts/layout.liquid"
57
- output = `diff -U 3 #{File.join(FIXTURE_PATH, file_name)} #{File.join(TMP_PATH, "shiny", file_name)}`
58
- $?.should.be.success
59
-
60
- output = `git log --pretty=oneline`.split("\n")
61
- output.length.should == 2
62
- output[0].should =~ /Braid: Add mirror 'skit1' at r1/
63
- end
64
-
65
- it "should create .braids and add the mirror to it" do
66
- in_dir(@shiny) do
67
- `#{BRAID_BIN} add --type svn #{@skit1}`
68
- end
69
-
70
- braids = YAML::load_file("#{@shiny}/.braids")
71
- braids["skit1"]["squashed"].should == true
72
- braids["skit1"]["url"].should == @skit1
73
- braids["skit1"]["type"].should == "svn"
74
- braids["skit1"]["revision"].should == 1
75
- braids["skit1"]["remote"].should == "braid/skit1"
76
- braids["skit1"]["branch"].should.be == nil
77
- end
78
- end
79
-
80
- end
@@ -1,70 +0,0 @@
1
- require 'rubygems'
2
- require 'test/spec'
3
- require 'mocha'
4
-
5
- require 'tempfile'
6
- require 'fileutils'
7
- require 'pathname'
8
-
9
- TMP_PATH = File.join(Dir.tmpdir, "braid_integration")
10
- BRAID_PATH = Pathname.new(File.dirname(__FILE__)).parent.realpath
11
- FIXTURE_PATH = File.join(BRAID_PATH, "test", "fixtures")
12
- FileUtils.rm_rf(TMP_PATH)
13
- FileUtils.mkdir_p(TMP_PATH)
14
- BRAID_BIN = File.join(BRAID_PATH, "bin", "braid")
15
-
16
- #def exec(cmd)
17
- # `cd #{TMP} && #{cmd}`
18
- #end
19
-
20
- def in_dir(dir = TMP_PATH)
21
- Dir.chdir(dir)
22
- yield
23
- end
24
-
25
- def run_cmds(ary)
26
- ary.each do |cmd|
27
- cmd = cmd.strip!
28
- out = `#{cmd}`
29
- end
30
- end
31
-
32
- def update_dir_from_fixture(dir, fixture = dir)
33
- to_dir = File.join(TMP_PATH, dir)
34
- FileUtils.mkdir_p(to_dir)
35
- FileUtils.cp_r(File.join(FIXTURE_PATH, fixture) + "/.", to_dir)
36
- end
37
-
38
- def create_git_repo_from_fixture(fixture_name)
39
- git_repo = File.join(TMP_PATH, fixture_name)
40
- update_dir_from_fixture(fixture_name)
41
-
42
- in_dir(git_repo) do
43
- run_cmds(<<-EOD)
44
- git init
45
- git add *
46
- git commit -m "initial commit of #{fixture_name}"
47
- EOD
48
- end
49
-
50
- git_repo
51
- end
52
-
53
- def create_svn_repo_from_fixture(fixture_name)
54
- svn_wc = File.join(TMP_PATH, fixture_name + "_wc")
55
- svn_repo = File.join(TMP_PATH, fixture_name)
56
- run_cmds(<<-EOD)
57
- svnadmin create #{svn_repo}
58
- svn co file://#{svn_repo} #{svn_wc}
59
- EOD
60
- update_dir_from_fixture(fixture_name + "_wc", fixture_name)
61
- in_dir(svn_wc) do
62
- run_cmds(<<-EOD)
63
- svn add *
64
- svn commit -m "initial commit of #{fixture_name}"
65
- EOD
66
- end
67
- "file://#{svn_repo}"
68
- end
69
-
70
-