braid 1.0.20 → 1.0.21

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: 2d55b46eb72620ccc9092841609eda270aee04f6
4
- data.tar.gz: 684c604750e8774035de42d48c071a9796719be2
3
+ metadata.gz: a27f551df379a0352a7631473cb4fd0846972c36
4
+ data.tar.gz: e06e3fda1d7876be1062b2a4a37a3455bfadeb06
5
5
  SHA512:
6
- metadata.gz: 12781c901dc784fffa89b9d16ff941cafb3d9edc9f32435826a0654529962ea736731bab75959c94d4059357772d69211e2d670f1e848fd7733b92613f359c55
7
- data.tar.gz: 5cee8e7cbd85eb2fdc40b8a86dafdb89b2808aa5453a0a832158d1f88b2692a71e892a982d3e5752120497220834e193113cdcadb8ff913191776fb6df7c7586
6
+ metadata.gz: e3b359b14dd78c3eb9c74ba40e00715f1028633b9463b734d157a2907d587c1846087924afb15dfcbb0e7bb633ebdb95a8d829ce0dd47950bf0c350944c09ec1
7
+ data.tar.gz: a6cd4f1949074ab61fee5919f80458194c22063bdbce1a307d2cc7add311a7dd1e63ba94486d2d98cb310cd49f6b1c73edc65521f7c549a51a0ce0f7eb01ecd0
data/bin/braid CHANGED
@@ -20,6 +20,19 @@ Main {
20
20
  You can then merge back or cherry-pick changes.
21
21
  TXT
22
22
 
23
+ # Duplicated from Braid::Command.run. :(
24
+ def die(msg)
25
+ puts "Braid: Error: #{msg}"
26
+ exit(1)
27
+ end
28
+
29
+ # The "main" library doesn't provide a way to do this??
30
+ def check_no_extra_args!
31
+ if @argv.length > 0
32
+ die 'Extra argument(s) passed to command.'
33
+ end
34
+ end
35
+
23
36
  mode(:add) {
24
37
  description <<-TXT
25
38
  Add a new mirror to be tracked.
@@ -43,6 +56,7 @@ Main {
43
56
  mixin :argument_url, :optional_local_path, :option_branch, :option_tag, :option_revision, :option_verbose, :option_path
44
57
 
45
58
  run {
59
+ check_no_extra_args!
46
60
  Braid.verbose = verbose
47
61
  Braid::Command.run(:add, url, {'path' => local_path, 'branch' => branch, 'tag' => tag, 'revision' => revision, 'remote_path' => path})
48
62
  }
@@ -68,6 +82,7 @@ Main {
68
82
  mixin :optional_local_path, :option_head, :option_revision, :option_tag, :option_branch, :option_verbose, :option_keep_remote
69
83
 
70
84
  run {
85
+ check_no_extra_args!
71
86
  options = {
72
87
  'branch' => branch,
73
88
  'tag' => tag,
@@ -96,6 +111,7 @@ Main {
96
111
  mixin :argument_local_path, :option_verbose, :option_keep_remote
97
112
 
98
113
  run {
114
+ check_no_extra_args!
99
115
  options = {
100
116
  :keep => keep
101
117
  }
@@ -107,13 +123,24 @@ Main {
107
123
  mode(:diff) {
108
124
  description <<-TXT
109
125
  Show diff of local changes to mirror.
126
+
127
+ Additional arguments for "git diff" may be passed. "--" should be used to
128
+ ensure they are not parsed as Braid options. File paths to limit the diff are
129
+ relative to the downstream repository (for more convenient completion), even
130
+ though file paths in the diff are relative to the mirror.
110
131
  TXT
111
132
 
112
133
  mixin :optional_local_path, :option_verbose, :option_keep_remote
113
134
 
135
+ synopsis (Main::Usage.default_synopsis(self) + ' [-- git_diff_arg*]')
136
+
114
137
  run {
138
+ if @argv.length > 0 && @argv[0] == '--'
139
+ @argv.shift
140
+ end
115
141
  options = {
116
- 'keep' => keep
142
+ 'keep' => keep,
143
+ 'git_diff_args' => @argv
117
144
  }
118
145
  Braid.verbose = verbose
119
146
  Braid::Command.run(:diff, local_path, options)
@@ -128,6 +155,7 @@ Main {
128
155
  mixin :argument_local_path, :option_branch, :option_verbose, :option_keep_remote
129
156
 
130
157
  run {
158
+ check_no_extra_args!
131
159
  options = {
132
160
  'keep' => keep,
133
161
  'branch' => branch
@@ -145,6 +173,7 @@ Main {
145
173
  mixin :optional_local_path, :option_verbose, :option_force
146
174
 
147
175
  run {
176
+ check_no_extra_args!
148
177
  Braid.verbose = verbose
149
178
  Braid.force = force
150
179
  Braid::Command.run(:setup, local_path)
@@ -155,6 +184,7 @@ Main {
155
184
  description 'Show braid version.'
156
185
 
157
186
  run {
187
+ check_no_extra_args!
158
188
  puts "braid #{Braid::VERSION}"
159
189
  }
160
190
  }
@@ -165,6 +195,7 @@ Main {
165
195
  mixin :optional_local_path, :option_verbose
166
196
 
167
197
  run {
198
+ check_no_extra_args!
168
199
  Braid.verbose = verbose
169
200
  Braid::Command.run(:status, local_path)
170
201
  }
@@ -8,6 +8,7 @@ module Braid
8
8
 
9
9
  def self.run(command, *args)
10
10
  verify_git_version!
11
+ check_working_dir!
11
12
 
12
13
  klass = Commands.const_get(command.to_s.capitalize)
13
14
  klass.new.run(*args)
@@ -66,6 +67,17 @@ module Braid
66
67
  git.require_version!(REQUIRED_GIT_VERSION)
67
68
  end
68
69
 
70
+ def self.check_working_dir!
71
+ # If we aren't in a git repository at all, git.is_inside_worktree will
72
+ # propagate a "fatal: Not a git repository" ShellException.
73
+ unless git.is_inside_worktree
74
+ raise BraidError, 'Braid must run inside a git working tree.'
75
+ end
76
+ if git.relative_working_dir != ''
77
+ raise BraidError, 'Braid does not yet support running in a subdirectory of the working tree.'
78
+ end
79
+ end
80
+
69
81
  def bail_on_local_changes!
70
82
  git.ensure_clean!
71
83
  end
@@ -8,33 +8,46 @@ module Braid
8
8
  protected
9
9
 
10
10
  def diff_all(options = {})
11
- config.mirrors.each do |path|
12
- separator
13
- msg "Diffing #{path}\n"
14
- separator
15
- diff = perform_diff(path, options)
16
- puts diff unless diff.empty?
11
+ # We don't want "git diff" to invoke the pager once for each mirror.
12
+ # TODO: Invoke the default pager once for the entire output.
13
+ Operations::with_modified_environment({"GIT_PAGER" => ''}) do
14
+ config.mirrors.each do |path|
15
+ separator
16
+ msg "Diffing #{path}\n"
17
+ separator
18
+ show_diff(path, options)
19
+ end
17
20
  end
18
21
  end
19
22
 
20
23
  def diff_one(path, options = {})
21
- diff = perform_diff(path, options)
22
- puts diff unless diff.empty?
24
+ show_diff(path, options)
23
25
  end
24
26
 
25
27
  def separator
26
28
  puts "=======================================================\n"
27
29
  end
28
30
 
29
- def perform_diff(path, options = {})
31
+ def show_diff(path, options = {})
30
32
  mirror = config.get!(path)
31
33
  setup_remote(mirror)
32
34
 
33
- diff = mirror.diff
35
+ # We do not need to spend the time to copy the content outside the
36
+ # mirror from HEAD because --relative will exclude it anyway. Rename
37
+ # detection seems to apply only to the files included in the diff, so we
38
+ # shouldn't have another bug like
39
+ # https://github.com/cristibalan/braid/issues/41.
40
+ base_tree = git.make_tree_with_subtree(nil, mirror.path,
41
+ mirror.versioned_path(mirror.base_revision))
42
+ # Git 1.7.2.2 release notes mention a bug when --relative is used
43
+ # without a trailing slash, and our minimum git version is 1.6.0, so
44
+ # attempt to work around the bug here.
45
+ #
46
+ # XXX: Warn if the user specifies file paths that are outside the
47
+ # mirror? Currently, they just won't match anything.
48
+ git.diff_to_stdout("--relative=#{mirror.path}/", base_tree, options['git_diff_args'])
34
49
 
35
50
  clear_remote(mirror, options)
36
-
37
- diff
38
51
  end
39
52
  end
40
53
  end
@@ -93,8 +93,8 @@ module Braid
93
93
  in_error = false
94
94
  begin
95
95
  local_hash = git.rev_parse('HEAD')
96
- base_hash = generate_tree_hash(mirror, mirror.versioned_path(base_revision))
97
- remote_hash = generate_tree_hash(mirror, target_revision)
96
+ base_hash = git.make_tree_with_subtree('HEAD', mirror.path, mirror.versioned_path(base_revision))
97
+ remote_hash = git.make_tree_with_subtree('HEAD', mirror.path, target_revision)
98
98
  Operations::with_modified_environment({
99
99
  "GITHEAD_#{local_hash}" => 'HEAD',
100
100
  "GITHEAD_#{remote_hash}" => target_revision
@@ -144,6 +144,18 @@ module Braid
144
144
  [status, out, err]
145
145
  end
146
146
 
147
+ def system(cmd)
148
+ cmd.strip!
149
+
150
+ # Without this, "braid diff" output came out in the wrong order on Windows.
151
+ $stdout.flush
152
+ $stderr.flush
153
+ Operations::with_modified_environment({'LANG' => 'C'}) do
154
+ Kernel.system(cmd)
155
+ return $?
156
+ end
157
+ end
158
+
147
159
  def msg(str)
148
160
  puts "Braid: #{str}"
149
161
  end
@@ -170,6 +182,24 @@ module Braid
170
182
  end
171
183
  end
172
184
 
185
+ # If the current directory is not inside a git repository at all, this
186
+ # command will fail with "fatal: Not a git repository" and that will be
187
+ # propagated as a ShellExecutionError. is_inside_worktree can return
188
+ # false when inside a bare repository and in certain other rare cases such
189
+ # as when the GIT_WORK_TREE environment variable is set.
190
+ def is_inside_worktree
191
+ invoke(:rev_parse, '--is-inside-work-tree') == 'true'
192
+ end
193
+
194
+ # Get the prefix of the current directory relative to the worktree. Empty
195
+ # string if it's the root of the worktree, otherwise ends with a slash.
196
+ # In some cases in which the current directory is not inside a worktree at
197
+ # all, this will successfully return an empty string, so it may be
198
+ # desirable to check is_inside_worktree first.
199
+ def relative_working_dir
200
+ invoke(:rev_parse, '--show-prefix')
201
+ end
202
+
173
203
  def commit(message, *args)
174
204
  cmd = 'git commit --no-verify'
175
205
  if message # allow nil
@@ -309,6 +339,18 @@ module Braid
309
339
  end
310
340
  end
311
341
 
342
+ def make_tree_with_subtree(main_content, subtree_path, subtree_content)
343
+ with_temporary_index do
344
+ if main_content
345
+ read_tree_im(main_content)
346
+ rm_r_cached(subtree_path)
347
+ end
348
+ # Yes, if subtree_path == '', "git read-tree --prefix=/" works. :/
349
+ read_tree_prefix_i(subtree_content, subtree_path)
350
+ write_tree
351
+ end
352
+ end
353
+
312
354
  def config(args)
313
355
  invoke(:config, args) rescue nil
314
356
  end
@@ -336,6 +378,12 @@ module Braid
336
378
  out
337
379
  end
338
380
 
381
+ def diff_to_stdout(*args)
382
+ # For now, ignore the exit code. It can be 141 (SIGPIPE) if the user
383
+ # quits the pager before reading all the output.
384
+ system("git diff #{args.join(' ')}")
385
+ end
386
+
339
387
  def status_clean?
340
388
  status, out, err = exec('git status')
341
389
  !out.split("\n").grep(/nothing to commit/).empty?
@@ -1,3 +1,3 @@
1
1
  module Braid
2
- VERSION = '1.0.20'
2
+ VERSION = '1.0.21'.freeze
3
3
  end
@@ -0,0 +1 @@
1
+ I would write something here if I knew what this was...
@@ -0,0 +1,221 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml">
3
+ {{ '/feed/atom.xml' | assign_to: 'global_feed' }}
4
+ {{ '/feed/all_comments.xml' | assign_to: 'global_comments_feed' }}
5
+ <head>
6
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
7
+ <title>
8
+ {{ site.title }}
9
+ {% if site.current_section %}
10
+ - {{ site.current_section.name }}
11
+ {% endif %}
12
+ {% if article %}
13
+ - {{ article.title }}
14
+ {% endif %}
15
+ </title>
16
+ <link rel="alternate" type="application/atom+xml" title="{{ site.title }} feed" href="{{ global_feed }}"/>
17
+ <link rel="alternate" type="application/atom+xml" title="{{ site.title }} comments feed" href="{{ global_comments_feed }}"/>
18
+ {{ 'base' | stylesheet }}
19
+ {{ 'app' | javascript }}
20
+ <!--[if IE]>
21
+ {{ 'base_ie' | stylesheet }}
22
+ <![endif]-->
23
+ </head>
24
+
25
+ <body class="fixed green">
26
+ <script type="text/javascript">loadPreferences()</script>
27
+
28
+ <div id="wrapper">
29
+
30
+ <div id="header" class="clearfix">
31
+ <div id="title" class="clearfix">
32
+ <h1><a href="/">{{ site.title }}</a></h1>
33
+ </div>
34
+ <h2>Sections</h2>
35
+ <ul id="menu">
36
+ {% for section in site.sections %}
37
+ {% if section.articles_count > 0 %}
38
+ {% if section.is_home %}
39
+ <li{% if section.current %} class="selected"{% endif %}>{{ section | link_to_section }}</li>
40
+ {% else %}
41
+ {% if section.is_paged %}
42
+ <li{% if section.current %} class="selected"{% endif %}>{{ section | link_to_section }}</li>
43
+ {% endif %}
44
+ {% endif %}
45
+ {% endif %}
46
+ {% endfor %}
47
+ </ul>
48
+ </div>
49
+
50
+ <div id="contentwrapper" class="clearfix">
51
+
52
+ <div id="content">
53
+
54
+ <div id="innerwrapper">
55
+
56
+ <div class="article">
57
+ <div class="body">
58
+ <h2>Skittlish Tips'n'Tricks</h2>
59
+ <ul>
60
+ <li>Change the classes for the body tag to set your default site style. also change these in the app.js file (line 66).</li>
61
+ <li>Remove the scripts and the #options div if you don't want the option switcher.</li>
62
+ <li>The top menu shows the home section and the sections that are not blogs.</li>
63
+ <li>Email me at <a href="mailto:evil@che.lu">evil@che.lu</a> if you have any questions.</li>
64
+ <li>Happy hacking!</li>
65
+ </ul>
66
+ </div>
67
+ </div>
68
+
69
+ {{ content_for_layout }}
70
+
71
+ </div>
72
+
73
+ </div>
74
+
75
+ <div id="sidebar">
76
+
77
+ <div class="boxy short">
78
+ <h3>boxy short</h3>
79
+
80
+ <p>You can have, boxes with a short, tall or no background shade, just change the class of the containing div.</p>
81
+
82
+ <p>Have boxes with smaller text with the class "minor". See the "Recent" boxy below.</p>
83
+
84
+ <p>Happy boxying!</p>
85
+
86
+ </div>
87
+
88
+ <div id="search" class="boxy short">
89
+ <h3>Search</h3>
90
+ <form method="get" action="/search">
91
+ <fieldset>
92
+ <input class="text" type="text" id="q" value="" name="q"/>
93
+ </fieldset>
94
+ </form>
95
+ </div>
96
+
97
+ <div class="boxy tall minor">
98
+ <h3>Recent</h3>
99
+
100
+ <dl>
101
+ <dt>Articles <a class="feed" href="{{ global_feed }}"><span>feed</span></a></dt>
102
+ <dd>
103
+ <ul>
104
+ {% for article in site.latest_articles %}
105
+ <li>{{ article | link_to_article }} <em>({{ article.published_at | format_date: 'stub', true }})</em></li>
106
+ {% endfor %}
107
+ </ul>
108
+ </dd>
109
+
110
+ <dt>Comments <a class="feed" href="{{ global_comments_feed }}"><span>feed</span></a></dt>
111
+ <dd>
112
+ <ul>
113
+ {% for comment in site.latest_comments %}
114
+ <li>{{ comment.author_link }} on <a href="{{ comment.url }}#comment-{{ comment.id }}">{{ comment.title }}</a></li>
115
+ {% endfor %}
116
+ </ul>
117
+ </dd>
118
+ </dl>
119
+ </div>
120
+
121
+ <div class="boxy short">
122
+ <h3>Archives</h3>
123
+ <p>This would be much nicer with jamis' month_drop thingy.</p>
124
+ {{ '' | section | months | assign_to: 'home_section' }}
125
+ <ul>
126
+ {% for month in home_section.months %}
127
+ {{ home_section | monthly_articles: month | size | assign_to: 'articles_count' }}
128
+ {% if articles_count > 0 %}
129
+ <li>{{ home_section | link_to_month: month }} ({{ articles_count }})</li>
130
+ {% endif %}
131
+ {% endfor %}
132
+ </ul>
133
+ </div>
134
+
135
+ {% if site.blog_sections.size > 1 %}
136
+ <div class="boxy short">
137
+ <h3>Categories</h3>
138
+ <p>Lists only blog type categories with at least one article.</p>
139
+ <p>This list uses an ul. You could use a dl with only dd's in it for the same effect. Wouldn't be semantic tho.</p>
140
+ <ul class="sections">
141
+ {% for section in site.blog_sections %}
142
+ {% if section.articles_count > 0 %}
143
+ {% unless section.is_home %}
144
+ <li>{{ section | link_to_section }} ({{ section.articles_count }})</li>
145
+ {% endunless %}
146
+ {% endif %}
147
+ {% endfor %}
148
+ </ul>
149
+ </div>
150
+
151
+ {% endif %}
152
+ {% unless site.tags == empty %}
153
+ <div class="boxy short">
154
+ <p>This would be nicer if we could get the number of articles for each tag.</p>
155
+ <h3>tags: </h3>
156
+ <ul>
157
+ {% for tag in site.tags %}
158
+ <li>{{ tag | link_to_tag }}</li>
159
+ {% endfor %}
160
+ </ul>
161
+ </div>
162
+
163
+ {% endunless %}
164
+ <div class="boxy tall">
165
+ <h3>boxy tall</h3>
166
+ <p>When using a tall box, make sure it's got plenty of content or that it's immediately followed by a short boxy. It might look a bit chopped off otherwise.</p>
167
+ <dl>
168
+ <dt>thing 1</dt>
169
+ <dd><a href="#">value 1</a></dd>
170
+ <dd><a href="#">value 2</a></dd>
171
+ <dd><a href="#">value 3</a></dd>
172
+ <dd><a href="#">value 4</a></dd>
173
+ <dd><a href="#">value 5</a></dd>
174
+ <dd><a href="#">value 6</a></dd>
175
+ <dd><a href="#">value 6</a></dd>
176
+
177
+ <dt>thing 1</dt>
178
+ <dd><a href="#">value 1</a></dd>
179
+ <dd><a href="#">value 2</a></dd>
180
+ <dd><a href="#">value 3</a></dd>
181
+ <dd>value 4</dd>
182
+ <dd>value 5</dd>
183
+ <dd><a href="#">value 6</a></dd>
184
+ <dd><a href="#">value 6</a></dd>
185
+
186
+ </dl>
187
+ </div>
188
+
189
+ </div>
190
+
191
+ </div>
192
+
193
+ <div id="options">
194
+ <h2>Options:</h2>
195
+ <h3>Size</h3>
196
+ <ul id="option_size">
197
+ <li id="option_size_fixed" class="fixed" ><a><span>fixed </span></a></li>
198
+ <li id="option_size_fluid" class="fluid" ><a><span>fluid </span></a></li>
199
+ </ul>
200
+ <h3>Colors</h3>
201
+ <ul id="option_color">
202
+ <li id="option_color_orange" class="orange"><a><span>orange</span></a></li>
203
+ <li id="option_color_blue" class="blue" ><a><span>blue </span></a></li>
204
+ <li id="option_color_green" class="green" ><a><span>green </span></a></li>
205
+ <li id="option_color_pink" class="pink" ><a><span>pink </span></a></li>
206
+ <li id="option_color_cyan" class="cyan" ><a><span>cyan </span></a></li>
207
+ <li id="option_color_red" class="red" ><a><span>red </span></a></li>
208
+ <li id="option_color_violet" class="violet"><a><span>violet</span></a></li>
209
+ </ul>
210
+ </div>
211
+
212
+ <div id="footer">
213
+ <p>Copyright &copy; 2006, Your Name. Valid <a href="http://validator.w3.org/check/referer">XHTML</a> and <a href="http://jigsaw.w3.org/css-validator/check/referer">CSS</a>.</p>
214
+ <p>Using <a href="http://evil.che.lu/projects/skittlish">skittlish</a> on <a href="http://publishwithimpunity.com/">mephisto</a>.</p>
215
+ </div>
216
+
217
+ </div>
218
+
219
+ </body>
220
+
221
+ </html>
@@ -1,6 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/integration_helper'
2
2
 
3
- describe 'Running braid diff on a mirror' do
3
+ describe 'Running braid diff with a mirror' do
4
4
  before do
5
5
  FileUtils.rm_rf(TMP_PATH)
6
6
  FileUtils.mkdir_p(TMP_PATH)
@@ -19,7 +19,7 @@ describe 'Running braid diff on a mirror' do
19
19
  end
20
20
 
21
21
  describe 'with no changes' do
22
- it 'should emit no output when named in braid diff' do
22
+ it 'with the mirror specified should emit no output' do
23
23
  diff = nil
24
24
  in_dir(@repository_dir) do
25
25
  diff = run_command("#{BRAID_BIN} diff skit1")
@@ -28,7 +28,7 @@ describe 'Running braid diff on a mirror' do
28
28
  expect(diff).to eq('')
29
29
  end
30
30
 
31
- it 'should emit only banners when braid diff all' do
31
+ it 'without specifying a mirror should emit only banners' do
32
32
  diff = nil
33
33
  in_dir(@repository_dir) do
34
34
  diff = run_command("#{BRAID_BIN} diff")
@@ -47,7 +47,7 @@ describe 'Running braid diff on a mirror' do
47
47
  end
48
48
  end
49
49
 
50
- it 'should emit diff when named in braid diff' do
50
+ it 'with the mirror specified should emit diff' do
51
51
  diff = nil
52
52
  in_dir(@repository_dir) do
53
53
  diff = run_command("#{BRAID_BIN} diff skit1")
@@ -70,7 +70,7 @@ index 9f75009..25a4b32 100644
70
70
  PATCH
71
71
  end
72
72
 
73
- it 'should emit only banners when braid diff all' do
73
+ it 'without specifying a mirror should emit diff and banners' do
74
74
  diff = nil
75
75
  in_dir(@repository_dir) do
76
76
  diff = run_command("#{BRAID_BIN} diff")
@@ -93,6 +93,162 @@ index 9f75009..25a4b32 100644
93
93
  <script type="text/javascript">loadPreferences()</script>
94
94
 
95
95
  <div id="wrapper">
96
+ PATCH
97
+ end
98
+ end
99
+
100
+ describe 'with uncommitted changes (some staged)' do
101
+ before do
102
+ FileUtils.cp_r(File.join(FIXTURE_PATH, 'skit1.1') + '/.', "#{@repository_dir}/skit1")
103
+ in_dir(@repository_dir) do
104
+ run_command('git add *')
105
+ end
106
+ FileUtils.cp_r(File.join(FIXTURE_PATH, 'skit1.2') + '/.', "#{@repository_dir}/skit1")
107
+ # Now "orange" -> "green" is staged, "Happy boxying!" is unstaged.
108
+ end
109
+
110
+ it 'with the mirror specified should show all uncommitted changes' do
111
+ diff = nil
112
+ in_dir(@repository_dir) do
113
+ diff = run_command("#{BRAID_BIN} diff skit1")
114
+ end
115
+
116
+ expect(diff).to eq(<<PATCH)
117
+ diff --git a/layouts/layout.liquid b/layouts/layout.liquid
118
+ index 9f75009..7037e21 100644
119
+ --- a/layouts/layout.liquid
120
+ +++ b/layouts/layout.liquid
121
+ @@ -22,7 +22,7 @@
122
+ <![endif]-->
123
+ </head>
124
+
125
+ -<body class="fixed orange">
126
+ +<body class="fixed green">
127
+ <script type="text/javascript">loadPreferences()</script>
128
+
129
+ <div id="wrapper">
130
+ @@ -81,6 +81,8 @@
131
+
132
+ <p>Have boxes with smaller text with the class "minor". See the "Recent" boxy below.</p>
133
+
134
+ +<p>Happy boxying!</p>
135
+ +
136
+ </div>
137
+
138
+ <div id="search" class="boxy short">
139
+ PATCH
140
+ end
141
+
142
+ it 'without specifying a mirror should show all uncommitted changes with a banner' do
143
+ diff = nil
144
+ in_dir(@repository_dir) do
145
+ diff = run_command("#{BRAID_BIN} diff")
146
+ end
147
+
148
+ expect(diff).to eq(<<PATCH)
149
+ =======================================================
150
+ Braid: Diffing skit1
151
+ =======================================================
152
+ diff --git a/layouts/layout.liquid b/layouts/layout.liquid
153
+ index 9f75009..7037e21 100644
154
+ --- a/layouts/layout.liquid
155
+ +++ b/layouts/layout.liquid
156
+ @@ -22,7 +22,7 @@
157
+ <![endif]-->
158
+ </head>
159
+
160
+ -<body class="fixed orange">
161
+ +<body class="fixed green">
162
+ <script type="text/javascript">loadPreferences()</script>
163
+
164
+ <div id="wrapper">
165
+ @@ -81,6 +81,8 @@
166
+
167
+ <p>Have boxes with smaller text with the class "minor". See the "Recent" boxy below.</p>
168
+
169
+ +<p>Happy boxying!</p>
170
+ +
171
+ </div>
172
+
173
+ <div id="search" class="boxy short">
174
+ PATCH
175
+ end
176
+
177
+ it 'with the mirror specified and --cached should show only the staged uncommitted changes' do
178
+ diff = nil
179
+ in_dir(@repository_dir) do
180
+ diff = run_command("#{BRAID_BIN} diff skit1 -- --cached")
181
+ end
182
+
183
+ expect(diff).to eq(<<PATCH)
184
+ diff --git a/layouts/layout.liquid b/layouts/layout.liquid
185
+ index 9f75009..25a4b32 100644
186
+ --- a/layouts/layout.liquid
187
+ +++ b/layouts/layout.liquid
188
+ @@ -22,7 +22,7 @@
189
+ <![endif]-->
190
+ </head>
191
+
192
+ -<body class="fixed orange">
193
+ +<body class="fixed green">
194
+ <script type="text/javascript">loadPreferences()</script>
195
+
196
+ <div id="wrapper">
197
+ PATCH
198
+ end
199
+
200
+ it 'without specifying a mirror and with --cached should show only the staged uncommitted changes with a banner' do
201
+ diff = nil
202
+ in_dir(@repository_dir) do
203
+ diff = run_command("#{BRAID_BIN} diff -- --cached")
204
+ end
205
+
206
+ expect(diff).to eq(<<PATCH)
207
+ =======================================================
208
+ Braid: Diffing skit1
209
+ =======================================================
210
+ diff --git a/layouts/layout.liquid b/layouts/layout.liquid
211
+ index 9f75009..25a4b32 100644
212
+ --- a/layouts/layout.liquid
213
+ +++ b/layouts/layout.liquid
214
+ @@ -22,7 +22,7 @@
215
+ <![endif]-->
216
+ </head>
217
+
218
+ -<body class="fixed orange">
219
+ +<body class="fixed green">
220
+ <script type="text/javascript">loadPreferences()</script>
221
+
222
+ <div id="wrapper">
223
+ PATCH
224
+ end
225
+ end
226
+
227
+ describe 'with changes to multiple files and a file path argument' do
228
+ before do
229
+ FileUtils.cp_r(File.join(FIXTURE_PATH, 'skit1.3') + '/.', "#{@repository_dir}/skit1")
230
+ in_dir(@repository_dir) do
231
+ run_command('git add *')
232
+ run_command('git commit -m "Some local changes"')
233
+ end
234
+ end
235
+
236
+ it 'should show only the diff in the specified file' do
237
+ diff = nil
238
+ in_dir(@repository_dir) do
239
+ # Test that file paths are taken relative to the downstream repository
240
+ # root, as documented, rather than the mirror.
241
+ diff = run_command("#{BRAID_BIN} diff skit1 -- skit1/layouts/README.md")
242
+ end
243
+
244
+ expect(diff).to eq(<<PATCH)
245
+ diff --git a/layouts/README.md b/layouts/README.md
246
+ new file mode 100644
247
+ index 0000000..69dc7e6
248
+ --- /dev/null
249
+ +++ b/layouts/README.md
250
+ @@ -0,0 +1 @@
251
+ +I would write something here if I knew what this was...
96
252
  PATCH
97
253
  end
98
254
  end
@@ -106,7 +262,7 @@ PATCH
106
262
  end
107
263
 
108
264
  describe 'with no changes' do
109
- it 'should emit no output when named in braid diff' do
265
+ it 'with the mirror specified should emit no output' do
110
266
  diff = nil
111
267
  in_dir(@repository_dir) do
112
268
  diff = run_command("#{BRAID_BIN} diff skit1")
@@ -115,7 +271,7 @@ PATCH
115
271
  expect(diff).to eq('')
116
272
  end
117
273
 
118
- it 'should emit only banners when braid diff all' do
274
+ it 'without specifying a mirror should emit only banners' do
119
275
  diff = nil
120
276
  in_dir(@repository_dir) do
121
277
  diff = run_command("#{BRAID_BIN} diff")
@@ -135,7 +291,7 @@ PATCH
135
291
  end
136
292
  end
137
293
 
138
- it 'should emit diff when named in braid diff' do
294
+ it 'with the mirror specified should emit diff' do
139
295
  diff = nil
140
296
  in_dir(@repository_dir) do
141
297
  diff = run_command("#{BRAID_BIN} diff skit1")
@@ -158,7 +314,7 @@ index 9f75009..25a4b32 100644
158
314
  PATCH
159
315
  end
160
316
 
161
- it 'should emit only banners when braid diff all' do
317
+ it 'without specifying a mirror should emit diff and banners' do
162
318
  diff = nil
163
319
  in_dir(@repository_dir) do
164
320
  diff = run_command("#{BRAID_BIN} diff")
@@ -194,7 +350,7 @@ PATCH
194
350
  end
195
351
 
196
352
  describe 'with no changes' do
197
- it 'should emit no output when named in braid diff' do
353
+ it 'with the mirror specified should emit no output' do
198
354
  diff = nil
199
355
  in_dir(@repository_dir) do
200
356
  diff = run_command("#{BRAID_BIN} diff skit1")
@@ -203,7 +359,7 @@ PATCH
203
359
  expect(diff).to eq('')
204
360
  end
205
361
 
206
- it 'should emit only banners when braid diff all' do
362
+ it 'without specifying a mirror should emit only banners' do
207
363
  diff = nil
208
364
  in_dir(@repository_dir) do
209
365
  diff = run_command("#{BRAID_BIN} diff")
@@ -222,7 +378,7 @@ PATCH
222
378
  end
223
379
  end
224
380
 
225
- it 'should emit diff when named in braid diff' do
381
+ it 'with the mirror specified should emit diff' do
226
382
  diff = nil
227
383
  in_dir(@repository_dir) do
228
384
  diff = run_command("#{BRAID_BIN} diff skit1")
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.20
4
+ version: 1.0.21
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-05-22 00:00:00.000000000 Z
13
+ date: 2017-05-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: main
@@ -110,6 +110,8 @@ files:
110
110
  - spec/fixtures/shiny_skit1_mergeable/preview.png
111
111
  - spec/fixtures/skit1.1/layouts/layout.liquid
112
112
  - spec/fixtures/skit1.2/layouts/layout.liquid
113
+ - spec/fixtures/skit1.3/layouts/README.md
114
+ - spec/fixtures/skit1.3/layouts/layout.liquid
113
115
  - spec/fixtures/skit1/layouts/layout.liquid
114
116
  - spec/fixtures/skit1/preview.png
115
117
  - spec/integration/adding_spec.rb