braid 1.0.10 → 1.0.11
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.
- checksums.yaml +4 -4
 - data/bin/braid +31 -8
 - data/lib/braid.rb +1 -0
 - data/lib/braid/command.rb +4 -0
 - data/lib/braid/commands/add.rb +2 -0
 - data/lib/braid/commands/diff.rb +22 -1
 - data/lib/braid/commands/list.rb +2 -30
 - data/lib/braid/commands/push.rb +2 -0
 - data/lib/braid/commands/setup.rb +1 -1
 - data/lib/braid/commands/status.rb +42 -0
 - data/lib/braid/commands/update.rb +9 -6
 - data/lib/braid/mirror.rb +5 -11
 - data/lib/braid/operations.rb +1 -10
 - data/lib/braid/version.rb +1 -1
 - data/spec/integration/adding_spec.rb +0 -1
 - data/spec/mirror_spec.rb +5 -0
 - metadata +3 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: cab5b4a0635df158bf25ffe1fa9d32f5b7f3bf30
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: b435890d0ed321e80b89cb56b71a46c6e638add8
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 16333b71784a667c94a8250e26f0ce82c5edf73060b388538cb5fbdf9cd892aab10fef7375e50592d358c0e8e90cc4cd693ec94120e7c448169fb639a47cdf76
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: c65b7965793f1a0350e480f9eb395073e2a875a7a42f2d5c4d900effe63a9d3af8c70ae092c043829815ecfd73afbbf1e19f806c2cd1ac1840b6c4595ece9301
         
     | 
    
        data/bin/braid
    CHANGED
    
    | 
         @@ -55,6 +55,7 @@ Main { 
     | 
|
| 
       55 
55 
     | 
    
         
             
                    * get new changes from remote
         
     | 
| 
       56 
56 
     | 
    
         
             
                    * always creates a merge commit
         
     | 
| 
       57 
57 
     | 
    
         
             
                    * updates metadata in .braids.json when revisions are changed
         
     | 
| 
      
 58 
     | 
    
         
            +
                    * removes the git remote by default, --keep can be used to suppress that
         
     | 
| 
       58 
59 
     | 
    
         | 
| 
       59 
60 
     | 
    
         
             
                  Defaults to updating all unlocked mirrors if none is specified.
         
     | 
| 
       60 
61 
     | 
    
         
             
                TXT
         
     | 
| 
         @@ -64,11 +65,16 @@ Main { 
     | 
|
| 
       64 
65 
     | 
    
         
             
                  . braid update local/dir
         
     | 
| 
       65 
66 
     | 
    
         
             
                TXT
         
     | 
| 
       66 
67 
     | 
    
         | 
| 
       67 
     | 
    
         
            -
                mixin :optional_path, :option_revision, :option_head, :option_verbose
         
     | 
| 
      
 68 
     | 
    
         
            +
                mixin :optional_path, :option_revision, :option_head, :option_verbose, :option_keep_remote
         
     | 
| 
       68 
69 
     | 
    
         | 
| 
       69 
70 
     | 
    
         
             
                run {
         
     | 
| 
      
 71 
     | 
    
         
            +
                  options = {
         
     | 
| 
      
 72 
     | 
    
         
            +
                    'revision' => revision,
         
     | 
| 
      
 73 
     | 
    
         
            +
                    'head' => head,
         
     | 
| 
      
 74 
     | 
    
         
            +
                    'keep' => keep
         
     | 
| 
      
 75 
     | 
    
         
            +
                  }
         
     | 
| 
       70 
76 
     | 
    
         
             
                  Braid.verbose = verbose
         
     | 
| 
       71 
     | 
    
         
            -
                  Braid::Command.run(:update, path,  
     | 
| 
      
 77 
     | 
    
         
            +
                  Braid::Command.run(:update, path, options)
         
     | 
| 
       72 
78 
     | 
    
         
             
                }
         
     | 
| 
       73 
79 
     | 
    
         
             
              }
         
     | 
| 
       74 
80 
     | 
    
         | 
| 
         @@ -88,8 +94,8 @@ Main { 
     | 
|
| 
       88 
94 
     | 
    
         
             
                mixin :argument_path, :option_verbose, :option_keep_remote
         
     | 
| 
       89 
95 
     | 
    
         | 
| 
       90 
96 
     | 
    
         
             
                run {
         
     | 
| 
       91 
     | 
    
         
            -
                  options 
     | 
| 
       92 
     | 
    
         
            -
             
     | 
| 
      
 97 
     | 
    
         
            +
                  options = {
         
     | 
| 
      
 98 
     | 
    
         
            +
                    :keep => keep
         
     | 
| 
       93 
99 
     | 
    
         
             
                  }
         
     | 
| 
       94 
100 
     | 
    
         
             
                  Braid.verbose = verbose
         
     | 
| 
       95 
101 
     | 
    
         
             
                  Braid::Command.run(:remove, path, options)
         
     | 
| 
         @@ -101,10 +107,13 @@ Main { 
     | 
|
| 
       101 
107 
     | 
    
         
             
                  Show diff of local changes to mirror.
         
     | 
| 
       102 
108 
     | 
    
         
             
                TXT
         
     | 
| 
       103 
109 
     | 
    
         | 
| 
       104 
     | 
    
         
            -
                mixin : 
     | 
| 
      
 110 
     | 
    
         
            +
                mixin :optional_path, :option_verbose, :option_keep_remote
         
     | 
| 
       105 
111 
     | 
    
         | 
| 
       106 
112 
     | 
    
         
             
                run {
         
     | 
| 
       107 
     | 
    
         
            -
                   
     | 
| 
      
 113 
     | 
    
         
            +
                  options = {
         
     | 
| 
      
 114 
     | 
    
         
            +
                    'keep' => keep
         
     | 
| 
      
 115 
     | 
    
         
            +
                  }
         
     | 
| 
      
 116 
     | 
    
         
            +
                  Braid::Command.run(:diff, path, options)
         
     | 
| 
       108 
117 
     | 
    
         
             
                }
         
     | 
| 
       109 
118 
     | 
    
         
             
              }
         
     | 
| 
       110 
119 
     | 
    
         | 
| 
         @@ -113,11 +122,14 @@ Main { 
     | 
|
| 
       113 
122 
     | 
    
         
             
                  Push local mirror changes to remote.
         
     | 
| 
       114 
123 
     | 
    
         
             
                TXT
         
     | 
| 
       115 
124 
     | 
    
         | 
| 
       116 
     | 
    
         
            -
                mixin :argument_path, :option_verbose
         
     | 
| 
      
 125 
     | 
    
         
            +
                mixin :argument_path, :option_verbose, :option_keep_remote
         
     | 
| 
       117 
126 
     | 
    
         | 
| 
       118 
127 
     | 
    
         
             
                run {
         
     | 
| 
      
 128 
     | 
    
         
            +
                  options = {
         
     | 
| 
      
 129 
     | 
    
         
            +
                    'keep' => keep
         
     | 
| 
      
 130 
     | 
    
         
            +
                  }
         
     | 
| 
       119 
131 
     | 
    
         
             
                  Braid.verbose = verbose
         
     | 
| 
       120 
     | 
    
         
            -
                  Braid::Command.run(:push, path)
         
     | 
| 
      
 132 
     | 
    
         
            +
                  Braid::Command.run(:push, path, options)
         
     | 
| 
       121 
133 
     | 
    
         
             
                }
         
     | 
| 
       122 
134 
     | 
    
         
             
              }
         
     | 
| 
       123 
135 
     | 
    
         | 
| 
         @@ -154,6 +166,17 @@ Main { 
     | 
|
| 
       154 
166 
     | 
    
         
             
                }
         
     | 
| 
       155 
167 
     | 
    
         
             
              }
         
     | 
| 
       156 
168 
     | 
    
         | 
| 
      
 169 
     | 
    
         
            +
              mode(:status) {
         
     | 
| 
      
 170 
     | 
    
         
            +
                description 'Show the status of all tracked mirrors (and if updates are available).'
         
     | 
| 
      
 171 
     | 
    
         
            +
             
     | 
| 
      
 172 
     | 
    
         
            +
                mixin :optional_path, :option_verbose
         
     | 
| 
      
 173 
     | 
    
         
            +
             
     | 
| 
      
 174 
     | 
    
         
            +
                run {
         
     | 
| 
      
 175 
     | 
    
         
            +
                  Braid.verbose = verbose
         
     | 
| 
      
 176 
     | 
    
         
            +
                  Braid::Command.run(:status, path)
         
     | 
| 
      
 177 
     | 
    
         
            +
                }
         
     | 
| 
      
 178 
     | 
    
         
            +
              }
         
     | 
| 
      
 179 
     | 
    
         
            +
             
     | 
| 
       157 
180 
     | 
    
         
             
              mixin(:argument_path) {
         
     | 
| 
       158 
181 
     | 
    
         
             
                argument(:path) {
         
     | 
| 
       159 
182 
     | 
    
         
             
                  attr
         
     | 
    
        data/lib/braid.rb
    CHANGED
    
    
    
        data/lib/braid/command.rb
    CHANGED
    
    
    
        data/lib/braid/commands/add.rb
    CHANGED
    
    
    
        data/lib/braid/commands/diff.rb
    CHANGED
    
    | 
         @@ -1,12 +1,33 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module Braid
         
     | 
| 
       2 
2 
     | 
    
         
             
              module Commands
         
     | 
| 
       3 
3 
     | 
    
         
             
                class Diff < Command
         
     | 
| 
       4 
     | 
    
         
            -
                  def run(path)
         
     | 
| 
      
 4 
     | 
    
         
            +
                  def run(path = nil, options = {})
         
     | 
| 
      
 5 
     | 
    
         
            +
                    with_reset_on_error do
         
     | 
| 
      
 6 
     | 
    
         
            +
                      path ? diff_one(path, options) : diff_all(options)
         
     | 
| 
      
 7 
     | 
    
         
            +
                    end
         
     | 
| 
      
 8 
     | 
    
         
            +
                  end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                  protected
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                   def diff_all(options = {})
         
     | 
| 
      
 13 
     | 
    
         
            +
                    print "\n"
         
     | 
| 
      
 14 
     | 
    
         
            +
                    msg "Diffing all mirrors.\n=======================================================\n"
         
     | 
| 
      
 15 
     | 
    
         
            +
                    config.mirrors.each do |path|
         
     | 
| 
      
 16 
     | 
    
         
            +
                      msg "Diffing #{path}\n=======================================================\n"
         
     | 
| 
      
 17 
     | 
    
         
            +
                      diff_one(path, options)
         
     | 
| 
      
 18 
     | 
    
         
            +
                      msg "=======================================================\n"
         
     | 
| 
      
 19 
     | 
    
         
            +
                    end
         
     | 
| 
      
 20 
     | 
    
         
            +
                    print "\n"
         
     | 
| 
      
 21 
     | 
    
         
            +
                  end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                  def diff_one(path, options = {})
         
     | 
| 
       5 
24 
     | 
    
         
             
                    mirror = config.get!(path)
         
     | 
| 
       6 
25 
     | 
    
         
             
                    setup_remote(mirror)
         
     | 
| 
       7 
26 
     | 
    
         | 
| 
       8 
27 
     | 
    
         
             
                    diff = mirror.diff
         
     | 
| 
       9 
28 
     | 
    
         
             
                    puts diff unless diff.empty?
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                    clear_remote(mirror, options)
         
     | 
| 
       10 
31 
     | 
    
         
             
                  end
         
     | 
| 
       11 
32 
     | 
    
         
             
                end
         
     | 
| 
       12 
33 
     | 
    
         
             
              end
         
     | 
    
        data/lib/braid/commands/list.rb
    CHANGED
    
    | 
         @@ -2,37 +2,9 @@ module Braid 
     | 
|
| 
       2 
2 
     | 
    
         
             
              module Commands
         
     | 
| 
       3 
3 
     | 
    
         
             
                class List < Command
         
     | 
| 
       4 
4 
     | 
    
         
             
                  def run(path = nil, options = {})
         
     | 
| 
       5 
     | 
    
         
            -
                     
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
                    end
         
     | 
| 
      
 5 
     | 
    
         
            +
                    msg "WARNING: list command is deprecated. Please use \"braid status\" instead.\n"
         
     | 
| 
      
 6 
     | 
    
         
            +
                    Command.run(:status, path, options)
         
     | 
| 
       8 
7 
     | 
    
         
             
                  end
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
                  protected
         
     | 
| 
       11 
     | 
    
         
            -
                  def list_all(options = {})
         
     | 
| 
       12 
     | 
    
         
            -
                    options.reject! { |k, v| %w(revision head).include?(k) }
         
     | 
| 
       13 
     | 
    
         
            -
                    print "\n"
         
     | 
| 
       14 
     | 
    
         
            -
                    msg "Listing all mirrors.\n=======================================================\n"
         
     | 
| 
       15 
     | 
    
         
            -
                    config.mirrors.each do |path|
         
     | 
| 
       16 
     | 
    
         
            -
                      mirror = config.get!(path)
         
     | 
| 
       17 
     | 
    
         
            -
                      print path.to_s
         
     | 
| 
       18 
     | 
    
         
            -
                      print ' (' + mirror.base_revision + ')'
         
     | 
| 
       19 
     | 
    
         
            -
                      print ' [LOCKED]' if mirror.locked?
         
     | 
| 
       20 
     | 
    
         
            -
                      setup_remote(mirror)
         
     | 
| 
       21 
     | 
    
         
            -
                      msg "Fetching new commits for '#{mirror.path}'." if verbose?
         
     | 
| 
       22 
     | 
    
         
            -
                      mirror.fetch
         
     | 
| 
       23 
     | 
    
         
            -
                      new_revision    = validate_new_revision(mirror, options['revision'])
         
     | 
| 
       24 
     | 
    
         
            -
                      print ' (Remote Modified)' if new_revision.to_s != mirror.base_revision.to_s
         
     | 
| 
       25 
     | 
    
         
            -
                      local_file_count = git.read_ls_files(mirror.path).split.size
         
     | 
| 
       26 
     | 
    
         
            -
                      if 0 == local_file_count
         
     | 
| 
       27 
     | 
    
         
            -
                        print ' (Removed Locally)'
         
     | 
| 
       28 
     | 
    
         
            -
                      elsif !mirror.diff.empty?
         
     | 
| 
       29 
     | 
    
         
            -
                        print ' (Locally Modified)'
         
     | 
| 
       30 
     | 
    
         
            -
                      end
         
     | 
| 
       31 
     | 
    
         
            -
                      print "\n"
         
     | 
| 
       32 
     | 
    
         
            -
                    end
         
     | 
| 
       33 
     | 
    
         
            -
                    print "\n"
         
     | 
| 
       34 
     | 
    
         
            -
                  end
         
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
8 
     | 
    
         
             
                end
         
     | 
| 
       37 
9 
     | 
    
         
             
              end
         
     | 
| 
       38 
10 
     | 
    
         
             
            end
         
     | 
    
        data/lib/braid/commands/push.rb
    CHANGED
    
    
    
        data/lib/braid/commands/setup.rb
    CHANGED
    
    | 
         @@ -27,7 +27,7 @@ module Braid 
     | 
|
| 
       27 
27 
     | 
    
         
             
                      end
         
     | 
| 
       28 
28 
     | 
    
         
             
                    end
         
     | 
| 
       29 
29 
     | 
    
         | 
| 
       30 
     | 
    
         
            -
                    msg "Setup: Creating remote for '#{mirror.path}'."
         
     | 
| 
      
 30 
     | 
    
         
            +
                    msg "Setup: Creating remote for '#{mirror.path}'." if verbose?
         
     | 
| 
       31 
31 
     | 
    
         
             
                    url = use_local_cache? ? git_cache.path(mirror.url) : mirror.url
         
     | 
| 
       32 
32 
     | 
    
         
             
                    git.remote_add(mirror.remote, url, mirror.branch)
         
     | 
| 
       33 
33 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -0,0 +1,42 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Braid
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Commands
         
     | 
| 
      
 3 
     | 
    
         
            +
                class Status < Command
         
     | 
| 
      
 4 
     | 
    
         
            +
                  def run(path = nil, options = {})
         
     | 
| 
      
 5 
     | 
    
         
            +
                    with_reset_on_error do
         
     | 
| 
      
 6 
     | 
    
         
            +
                      path ? status_one(path, options) : status_all(options)
         
     | 
| 
      
 7 
     | 
    
         
            +
                    end
         
     | 
| 
      
 8 
     | 
    
         
            +
                  end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                  protected
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                  def status_all(options = {})
         
     | 
| 
      
 13 
     | 
    
         
            +
                    print "\n"
         
     | 
| 
      
 14 
     | 
    
         
            +
                    msg "Listing all mirrors.\n=======================================================\n"
         
     | 
| 
      
 15 
     | 
    
         
            +
                    config.mirrors.each do |path|
         
     | 
| 
      
 16 
     | 
    
         
            +
                      list_one(path, options)
         
     | 
| 
      
 17 
     | 
    
         
            +
                    end
         
     | 
| 
      
 18 
     | 
    
         
            +
                    print "\n"
         
     | 
| 
      
 19 
     | 
    
         
            +
                  end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                  def status_one(path, options = {})
         
     | 
| 
      
 22 
     | 
    
         
            +
                    mirror = config.get!(path)
         
     | 
| 
      
 23 
     | 
    
         
            +
                    setup_remote(mirror)
         
     | 
| 
      
 24 
     | 
    
         
            +
                    mirror.fetch
         
     | 
| 
      
 25 
     | 
    
         
            +
                    print path.to_s
         
     | 
| 
      
 26 
     | 
    
         
            +
                    print ' (' + mirror.base_revision + ')'
         
     | 
| 
      
 27 
     | 
    
         
            +
                    print ' [LOCKED]' if mirror.locked?
         
     | 
| 
      
 28 
     | 
    
         
            +
                    msg "Fetching new commits for '#{mirror.path}'." if verbose?
         
     | 
| 
      
 29 
     | 
    
         
            +
                    new_revision = validate_new_revision(mirror, options['revision'])
         
     | 
| 
      
 30 
     | 
    
         
            +
                    print ' (Remote Modified)' if new_revision.to_s != mirror.base_revision.to_s
         
     | 
| 
      
 31 
     | 
    
         
            +
                    local_file_count = git.read_ls_files(mirror.path).split.size
         
     | 
| 
      
 32 
     | 
    
         
            +
                    if 0 == local_file_count
         
     | 
| 
      
 33 
     | 
    
         
            +
                      print ' (Removed Locally)'
         
     | 
| 
      
 34 
     | 
    
         
            +
                    elsif !mirror.diff.empty?
         
     | 
| 
      
 35 
     | 
    
         
            +
                      print ' (Locally Modified)'
         
     | 
| 
      
 36 
     | 
    
         
            +
                    end
         
     | 
| 
      
 37 
     | 
    
         
            +
                    print "\n"
         
     | 
| 
      
 38 
     | 
    
         
            +
                    clear_remote(mirror, options)
         
     | 
| 
      
 39 
     | 
    
         
            +
                  end
         
     | 
| 
      
 40 
     | 
    
         
            +
                end
         
     | 
| 
      
 41 
     | 
    
         
            +
              end
         
     | 
| 
      
 42 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -2,9 +2,7 @@ module Braid 
     | 
|
| 
       2 
2 
     | 
    
         
             
              module Commands
         
     | 
| 
       3 
3 
     | 
    
         
             
                class Update < Command
         
     | 
| 
       4 
4 
     | 
    
         
             
                  def run(path, options = {})
         
     | 
| 
       5 
     | 
    
         
            -
                     
     | 
| 
       6 
     | 
    
         
            -
                      path ? update_one(path, options) : update_all(options)
         
     | 
| 
       7 
     | 
    
         
            -
                    end
         
     | 
| 
      
 5 
     | 
    
         
            +
                    path ? update_one(path, options) : update_all(options)
         
     | 
| 
       8 
6 
     | 
    
         
             
                  end
         
     | 
| 
       9 
7 
     | 
    
         | 
| 
       10 
8 
     | 
    
         
             
                  protected
         
     | 
| 
         @@ -13,6 +11,7 @@ module Braid 
     | 
|
| 
       13 
11 
     | 
    
         
             
                    options.reject! { |k, v| %w(revision head).include?(k) }
         
     | 
| 
       14 
12 
     | 
    
         
             
                    msg 'Updating all mirrors.'
         
     | 
| 
       15 
13 
     | 
    
         
             
                    config.mirrors.each do |path|
         
     | 
| 
      
 14 
     | 
    
         
            +
                      bail_on_local_changes!
         
     | 
| 
       16 
15 
     | 
    
         
             
                      update_one(path, options)
         
     | 
| 
       17 
16 
     | 
    
         
             
                    end
         
     | 
| 
       18 
17 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -44,13 +43,14 @@ module Braid 
     | 
|
| 
       44 
43 
     | 
    
         
             
                    begin
         
     | 
| 
       45 
44 
     | 
    
         
             
                      new_revision = validate_new_revision(mirror, options['revision'])
         
     | 
| 
       46 
45 
     | 
    
         
             
                    rescue InvalidRevision
         
     | 
| 
       47 
     | 
    
         
            -
                      # Ignored as it means the revision matches  
     | 
| 
      
 46 
     | 
    
         
            +
                      # Ignored as it means the revision matches expected
         
     | 
| 
       48 
47 
     | 
    
         
             
                    end
         
     | 
| 
       49 
48 
     | 
    
         
             
                    target_revision = determine_target_revision(new_revision)
         
     | 
| 
       50 
49 
     | 
    
         | 
| 
       51 
50 
     | 
    
         
             
                    if (options['revision'] && was_locked && target_revision == mirror.base_revision) ||
         
     | 
| 
       52 
51 
     | 
    
         
             
                      (options['revision'].nil? && !was_locked && mirror.merged?(target_revision))
         
     | 
| 
       53 
52 
     | 
    
         
             
                      msg "Mirror '#{mirror.path}' is already up to date."
         
     | 
| 
      
 53 
     | 
    
         
            +
                      clear_remote(mirror, options)
         
     | 
| 
       54 
54 
     | 
    
         
             
                      return
         
     | 
| 
       55 
55 
     | 
    
         
             
                    end
         
     | 
| 
       56 
56 
     | 
    
         | 
| 
         @@ -63,6 +63,7 @@ module Braid 
     | 
|
| 
       63 
63 
     | 
    
         
             
                    mirror.lock = new_revision if options['revision']
         
     | 
| 
       64 
64 
     | 
    
         | 
| 
       65 
65 
     | 
    
         
             
                    msg "Merging in mirror '#{mirror.path}'." if verbose?
         
     | 
| 
      
 66 
     | 
    
         
            +
                    in_error = false
         
     | 
| 
       66 
67 
     | 
    
         
             
                    begin
         
     | 
| 
       67 
68 
     | 
    
         
             
                      if mirror.squashed?
         
     | 
| 
       68 
69 
     | 
    
         
             
                        local_hash                    = git.rev_parse('HEAD')
         
     | 
| 
         @@ -75,6 +76,7 @@ module Braid 
     | 
|
| 
       75 
76 
     | 
    
         
             
                        git.merge_subtree(target_revision)
         
     | 
| 
       76 
77 
     | 
    
         
             
                      end
         
     | 
| 
       77 
78 
     | 
    
         
             
                    rescue Operations::MergeError => error
         
     | 
| 
      
 79 
     | 
    
         
            +
                      in_error = true
         
     | 
| 
       78 
80 
     | 
    
         
             
                      print error.conflicts_text
         
     | 
| 
       79 
81 
     | 
    
         
             
                      msg 'Caught merge error. Breaking.'
         
     | 
| 
       80 
82 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -83,13 +85,14 @@ module Braid 
     | 
|
| 
       83 
85 
     | 
    
         
             
                    add_config_file
         
     | 
| 
       84 
86 
     | 
    
         | 
| 
       85 
87 
     | 
    
         
             
                    commit_message = "Update mirror '#{mirror.path}' to #{display_revision(mirror)}"
         
     | 
| 
       86 
     | 
    
         
            -
                    if  
     | 
| 
      
 88 
     | 
    
         
            +
                    if in_error
         
     | 
| 
       87 
89 
     | 
    
         
             
                      File.open('.git/MERGE_MSG', 'w') { |f| f.puts(commit_message) }
         
     | 
| 
       88 
90 
     | 
    
         
             
                      return
         
     | 
| 
       89 
91 
     | 
    
         
             
                    end
         
     | 
| 
       90 
92 
     | 
    
         | 
| 
       91 
93 
     | 
    
         
             
                    git.commit(commit_message)
         
     | 
| 
       92 
94 
     | 
    
         
             
                    msg "Updated mirror to #{display_revision(mirror)}."
         
     | 
| 
      
 95 
     | 
    
         
            +
                    clear_remote(mirror, options)
         
     | 
| 
       93 
96 
     | 
    
         
             
                  end
         
     | 
| 
       94 
97 
     | 
    
         | 
| 
       95 
98 
     | 
    
         
             
                  def generate_tree_hash(mirror, revision)
         
     | 
| 
         @@ -97,7 +100,7 @@ module Braid 
     | 
|
| 
       97 
100 
     | 
    
         
             
                      git.read_tree_im('HEAD')
         
     | 
| 
       98 
101 
     | 
    
         
             
                      git.rm_r_cached(mirror.path)
         
     | 
| 
       99 
102 
     | 
    
         
             
                      git.read_tree_prefix_i(revision, mirror.path)
         
     | 
| 
       100 
     | 
    
         
            -
                      git.write_tree 
     | 
| 
      
 103 
     | 
    
         
            +
                      git.write_tree
         
     | 
| 
       101 
104 
     | 
    
         
             
                    end
         
     | 
| 
       102 
105 
     | 
    
         
             
                  end
         
     | 
| 
       103 
106 
     | 
    
         
             
                end
         
     | 
    
        data/lib/braid/mirror.rb
    CHANGED
    
    | 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module Braid
         
     | 
| 
       2 
2 
     | 
    
         
             
              class Mirror
         
     | 
| 
       3 
     | 
    
         
            -
                ATTRIBUTES = %w(url  
     | 
| 
      
 3 
     | 
    
         
            +
                ATTRIBUTES = %w(url branch squashed revision lock)
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
                class UnknownType < BraidError
         
     | 
| 
       6 
6 
     | 
    
         
             
                  def message
         
     | 
| 
         @@ -27,14 +27,12 @@ module Braid 
     | 
|
| 
       27 
27 
     | 
    
         | 
| 
       28 
28 
     | 
    
         
             
                  branch = options['branch'] || 'master'
         
     | 
| 
       29 
29 
     | 
    
         | 
| 
       30 
     | 
    
         
            -
                   
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
                  end
         
     | 
| 
      
 30 
     | 
    
         
            +
                  path = (options['path'] || extract_path_from_url(url)).sub(/\/$/, '')
         
     | 
| 
      
 31 
     | 
    
         
            +
                  raise PathRequired unless path
         
     | 
| 
       33 
32 
     | 
    
         | 
| 
       34 
     | 
    
         
            -
                  remote   = "#{branch}/braid/#{path}"
         
     | 
| 
       35 
33 
     | 
    
         
             
                  squashed = !options['full']
         
     | 
| 
       36 
34 
     | 
    
         | 
| 
       37 
     | 
    
         
            -
                  attributes = {'url' => url, ' 
     | 
| 
      
 35 
     | 
    
         
            +
                  attributes = {'url' => url, 'branch' => branch, 'squashed' => squashed}
         
     | 
| 
       38 
36 
     | 
    
         
             
                  self.new(path, attributes)
         
     | 
| 
       39 
37 
     | 
    
         
             
                end
         
     | 
| 
       40 
38 
     | 
    
         | 
| 
         @@ -90,11 +88,7 @@ module Braid 
     | 
|
| 
       90 
88 
     | 
    
         
             
                end
         
     | 
| 
       91 
89 
     | 
    
         | 
| 
       92 
90 
     | 
    
         
             
                def remote
         
     | 
| 
       93 
     | 
    
         
            -
                   
     | 
| 
       94 
     | 
    
         
            -
                    attributes['remote'] = "#{branch}/#{attributes['remote']}"
         
     | 
| 
       95 
     | 
    
         
            -
                  else
         
     | 
| 
       96 
     | 
    
         
            -
                    attributes['remote']
         
     | 
| 
       97 
     | 
    
         
            -
                  end
         
     | 
| 
      
 91 
     | 
    
         
            +
                  "#{branch}/braid/#{path}"
         
     | 
| 
       98 
92 
     | 
    
         
             
                end
         
     | 
| 
       99 
93 
     | 
    
         | 
| 
       100 
94 
     | 
    
         
             
                private
         
     | 
    
        data/lib/braid/operations.rb
    CHANGED
    
    | 
         @@ -147,14 +147,6 @@ module Braid 
     | 
|
| 
       147 
147 
     | 
    
         
             
                    [status, out, err]
         
     | 
| 
       148 
148 
     | 
    
         
             
                  end
         
     | 
| 
       149 
149 
     | 
    
         | 
| 
       150 
     | 
    
         
            -
                  def sh(cmd, message = nil)
         
     | 
| 
       151 
     | 
    
         
            -
                    message ||= 'could not fetch' if cmd =~ /fetch/
         
     | 
| 
       152 
     | 
    
         
            -
                    log(cmd)
         
     | 
| 
       153 
     | 
    
         
            -
                    `#{cmd}`
         
     | 
| 
       154 
     | 
    
         
            -
                    raise ShellExecutionError, message unless $?.exitstatus == 0
         
     | 
| 
       155 
     | 
    
         
            -
                    true
         
     | 
| 
       156 
     | 
    
         
            -
                  end
         
     | 
| 
       157 
     | 
    
         
            -
             
     | 
| 
       158 
150 
     | 
    
         
             
                  def msg(str)
         
     | 
| 
       159 
151 
     | 
    
         
             
                    puts "Braid: #{str}"
         
     | 
| 
       160 
152 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -193,8 +185,7 @@ module Braid 
     | 
|
| 
       193 
185 
     | 
    
         | 
| 
       194 
186 
     | 
    
         
             
                  def fetch(remote = nil, *args)
         
     | 
| 
       195 
187 
     | 
    
         
             
                    args.unshift "-n #{remote}" if remote
         
     | 
| 
       196 
     | 
    
         
            -
                    #  
     | 
| 
       197 
     | 
    
         
            -
                    sh("git fetch #{args.join(' ')} > #{Gem.win_platform? ? 'nul' : '/dev/null'}")
         
     | 
| 
      
 188 
     | 
    
         
            +
                    exec!("git fetch #{args.join(' ')} > #{Gem.win_platform? ? 'nul' : '/dev/null'}")
         
     | 
| 
       198 
189 
     | 
    
         
             
                  end
         
     | 
| 
       199 
190 
     | 
    
         | 
| 
       200 
191 
     | 
    
         
             
                  def checkout(treeish)
         
     | 
    
        data/lib/braid/version.rb
    CHANGED
    
    
| 
         @@ -36,7 +36,6 @@ describe 'Adding a mirror in a clean repository' do 
     | 
|
| 
       36 
36 
     | 
    
         
             
                  braids['skit1']['url'].should == @skit1
         
     | 
| 
       37 
37 
     | 
    
         
             
                  braids['skit1']['revision'].should_not be_nil
         
     | 
| 
       38 
38 
     | 
    
         
             
                  braids['skit1']['branch'].should == 'master'
         
     | 
| 
       39 
     | 
    
         
            -
                  braids['skit1']['remote'].should == 'master/braid/skit1'
         
     | 
| 
       40 
39 
     | 
    
         
             
                end
         
     | 
| 
       41 
40 
     | 
    
         
             
              end
         
     | 
| 
       42 
41 
     | 
    
         
             
            end
         
     | 
    
        data/spec/mirror_spec.rb
    CHANGED
    
    | 
         @@ -10,6 +10,11 @@ describe 'Braid::Mirror.new_from_options' do 
     | 
|
| 
       10 
10 
     | 
    
         
             
                new_from_options('http://path.git')
         
     | 
| 
       11 
11 
     | 
    
         
             
                @mirror.path.should == 'path'
         
     | 
| 
       12 
12 
     | 
    
         
             
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
              it 'should strip trailing slash from specified path' do
         
     | 
| 
      
 15 
     | 
    
         
            +
                new_from_options('http://path.git', 'path' => 'vendor/tools/mytool/')
         
     | 
| 
      
 16 
     | 
    
         
            +
                @mirror.path.should == 'vendor/tools/mytool'
         
     | 
| 
      
 17 
     | 
    
         
            +
              end
         
     | 
| 
       13 
18 
     | 
    
         
             
            end
         
     | 
| 
       14 
19 
     | 
    
         | 
| 
       15 
20 
     | 
    
         
             
            describe 'Braid::Mirror#diff' do
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: braid
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.0.11
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Cristi Balan
         
     | 
| 
         @@ -10,7 +10,7 @@ authors: 
     | 
|
| 
       10 
10 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       11 
11 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       12 
12 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       13 
     | 
    
         
            -
            date: 2017- 
     | 
| 
      
 13 
     | 
    
         
            +
            date: 2017-03-11 00:00:00.000000000 Z
         
     | 
| 
       14 
14 
     | 
    
         
             
            dependencies:
         
     | 
| 
       15 
15 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       16 
16 
     | 
    
         
             
              name: main
         
     | 
| 
         @@ -93,6 +93,7 @@ files: 
     | 
|
| 
       93 
93 
     | 
    
         
             
            - lib/braid/commands/push.rb
         
     | 
| 
       94 
94 
     | 
    
         
             
            - lib/braid/commands/remove.rb
         
     | 
| 
       95 
95 
     | 
    
         
             
            - lib/braid/commands/setup.rb
         
     | 
| 
      
 96 
     | 
    
         
            +
            - lib/braid/commands/status.rb
         
     | 
| 
       96 
97 
     | 
    
         
             
            - lib/braid/commands/update.rb
         
     | 
| 
       97 
98 
     | 
    
         
             
            - lib/braid/config.rb
         
     | 
| 
       98 
99 
     | 
    
         
             
            - lib/braid/mirror.rb
         
     |