<?xml version="1.0" encoding="UTF-8"?>
<ticket>
  <assigned-user-id type="integer" nil="true"></assigned-user-id>
  <attachments-count type="integer">1</attachments-count>
  <closed type="boolean">true</closed>
  <created-at type="datetime">2009-01-21T00:16:22+00:00</created-at>
  <creator-id type="integer">27076</creator-id>
  <milestone-due-on type="datetime" nil="true"></milestone-due-on>
  <milestone-id type="integer" nil="true"></milestone-id>
  <number type="integer">66</number>
  <permalink>add-git-clean-to-prevent-sub-module-detritus</permalink>
  <priority type="integer">0</priority>
  <project-id type="integer">8716</project-id>
  <raw-data type="binary" nil="true" encoding="base64"></raw-data>
  <state>hold</state>
  <tag>git patch</tag>
  <title>add git-clean to prevent sub-module detritus</title>
  <updated-at type="datetime">2009-08-04T10:20:56+01:00</updated-at>
  <user-id type="integer">1379</user-id>
  <user-name>Lee Hambley</user-name>
  <creator-name>Darrell Fuhriman</creator-name>
  <url>http://capistrano.lighthouseapp.com/projects/8716/tickets/66</url>
  <original-body>If a git submodule is removed through the course of development, its files will never be removed from the cached-copy, potentially causing problems in the deployed version.

See some discussion here: http://groups.google.com/group/capistrano/browse_thread/thread/a4ef2f940d090644

The attached patch adds a 'git clean' after the 'git reset --hard' to remove any remaining submodules.

Another possibility could be to optionally define a set of directories/files which the git clean would affect instead of acting on the entire repository.  For instance, only execute the git-clean in the vendor directory.</original-body>
  <latest-body>If a git submodule is removed through the course of development, its files will never be removed from the cached-copy, potentially causing problems in the deployed version.

See some discussion here: http://groups.google.com/group/capistrano/browse_thread/thread/a4ef2f940d090644

The attached patch adds a 'git clean' after the 'git reset --hard' to remove any remaining submodules.

Another possibility could be to optionally define a set of directories/files which the git clean would affect instead of acting on the entire repository.  For instance, only execute the git-clean in the vendor directory.</latest-body>
  <original-body-html>&lt;div&gt;&lt;p&gt;If a git submodule is removed through the course of development,
its files will never be removed from the cached-copy, potentially
causing problems in the deployed version.&lt;/p&gt;
&lt;p&gt;See some discussion here: &lt;a href=&quot;http://groups.google.com/group/capistrano/browse_thread/thread/a4ef2f940d090644&quot;&gt;
http://groups.google.com/group/c...&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The attached patch adds a 'git clean' after the 'git reset
--hard' to remove any remaining submodules.&lt;/p&gt;
&lt;p&gt;Another possibility could be to optionally define a set of
directories/files which the git clean would affect instead of
acting on the entire repository. For instance, only execute the
git-clean in the vendor directory.&lt;/p&gt;&lt;/div&gt;</original-body-html>
  <versions type="array">
    <version type="Ticket::Version">
      <assigned-user-id type="integer">15202</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>If a git submodule is removed through the course of development, its files will never be removed from the cached-copy, potentially causing problems in the deployed version.

See some discussion here: http://groups.google.com/group/capistrano/browse_thread/thread/a4ef2f940d090644

The attached patch adds a 'git clean' after the 'git reset --hard' to remove any remaining submodules.

Another possibility could be to optionally define a set of directories/files which the git clean would affect instead of acting on the entire repository.  For instance, only execute the git-clean in the vendor directory.</body>
      <body-html>&lt;div&gt;&lt;p&gt;If a git submodule is removed through the course of development,
its files will never be removed from the cached-copy, potentially
causing problems in the deployed version.&lt;/p&gt;
&lt;p&gt;See some discussion here: &lt;a href=&quot;http://groups.google.com/group/capistrano/browse_thread/thread/a4ef2f940d090644&quot;&gt;
http://groups.google.com/group/c...&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The attached patch adds a 'git clean' after the 'git reset
--hard' to remove any remaining submodules.&lt;/p&gt;
&lt;p&gt;Another possibility could be to optionally define a set of
directories/files which the git clean would affect instead of
acting on the entire repository. For instance, only execute the
git-clean in the vendor directory.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-01-21T00:16:22+00:00</created-at>
      <creator-id type="integer">27076</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">66</number>
      <permalink>add-git-clean-to-prevent-sub-module-detritus</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8716</project-id>
      <state>new</state>
      <tag>git patch</tag>
      <title>add git-clean to prevent sub-module detritus</title>
      <updated-at type="datetime">2009-01-21T00:16:24+00:00</updated-at>
      <user-id type="integer">27076</user-id>
      <user-name>Darrell Fuhriman</user-name>
      <creator-name>Darrell Fuhriman</creator-name>
      <url>http://capistrano.lighthouseapp.com/projects/8716/tickets/66</url>
      <assigned-user-name>Jamis Buck</assigned-user-name>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">15202</assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>I worry, somewhat, about using git clean like this. I'm not entirely sure that it wouldn't lead to a situation where files are removed that were not intended to be removed. It is true that if git.sync(...) is used only internally by the deployment code, this patch is probably fine. But the fact is that people continually surprise me with the ways they use this stuff, and I'd hate for someone to lose valuable files (like customer images or something) that just happened to be where we weren't expecting them to be.

The fact is, it's just not something you'd expect &quot;scm.sync&quot; to do: deleting untracked files.

I think it might be best if, instead of making the git clean part of the sync operation, you did it as a task that you hooked onto the end of the update-code hook. e.g.

@@@
task :cleanup_stuff do
  run &quot;cd #{release_path} &amp;&amp; git clean -dxf&quot;
end
after &quot;deploy:update_code&quot;, :cleanup_stuff
@@@

What are your thoughts on this? Does a post-update hook like that work in your case?</body>
      <body-html>&lt;div&gt;&lt;p&gt;I worry, somewhat, about using git clean like this. I'm not
entirely sure that it wouldn't lead to a situation where files are
removed that were not intended to be removed. It is true that if
git.sync(...) is used only internally by the deployment code, this
patch is probably fine. But the fact is that people continually
surprise me with the ways they use this stuff, and I'd hate for
someone to lose valuable files (like customer images or something)
that just happened to be where we weren't expecting them to be.&lt;/p&gt;
&lt;p&gt;The fact is, it's just not something you'd expect &quot;scm.sync&quot; to
do: deleting untracked files.&lt;/p&gt;
&lt;p&gt;I think it might be best if, instead of making the git clean
part of the sync operation, you did it as a task that you hooked
onto the end of the update-code hook. e.g.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
task :cleanup_stuff do
  run &amp;quot;cd #{release_path} &amp;amp;&amp;amp; git clean -dxf&amp;quot;
end
after &amp;quot;deploy:update_code&amp;quot;, :cleanup_stuff
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;What are your thoughts on this? Does a post-update hook like
that work in your case?&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-02-05T04:22:57+00:00</created-at>
      <creator-id type="integer">27076</creator-id>
      <diffable-attributes type="yaml">--- 
:state: new
</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">66</number>
      <permalink>add-git-clean-to-prevent-sub-module-detritus</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8716</project-id>
      <state>open</state>
      <tag>git patch</tag>
      <title>add git-clean to prevent sub-module detritus</title>
      <updated-at type="datetime">2009-02-05T04:23:00+00:00</updated-at>
      <user-id type="integer">15202</user-id>
      <user-name>Jamis Buck</user-name>
      <creator-name>Darrell Fuhriman</creator-name>
      <url>http://capistrano.lighthouseapp.com/projects/8716/tickets/66</url>
      <assigned-user-name>Jamis Buck</assigned-user-name>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">15202</assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>Yes, that should work.  It also occurs to me that simply finding and cleaning only removed submodule directories that are not tracked anymore might help. That should be relatively safe, although finding those directories is a bit of a pain.  Maybe like this:

if git_enable_submodules
  paths=`git whatchanged -m -p .gitmodules`.map{ |l| 
  if l =~ /^-\s+path\s*=\s*(.*)/
    $1
  else 
    nil
  end
  }.compact
  untracked=`git ls-files --others --exclude-standard --directory`.split(&quot;\n&quot;)
  paths.each do |p|
   next unless untracked[p]
    `git clean -df #{p}`
  end
end

Although I have to admit I'm worried it would be a bit too fragile, but then again, maybe not.</body>
      <body-html>&lt;div&gt;&lt;p&gt;Yes, that should work. It also occurs to me that simply finding
and cleaning only removed submodule directories that are not
tracked anymore might help. That should be relatively safe,
although finding those directories is a bit of a pain. Maybe like
this:&lt;/p&gt;
&lt;p&gt;if git_enable_submodules paths=&lt;code&gt;git whatchanged -m -p
.gitmodules&lt;/code&gt;.map{ |l| if l =~
/^-\s+path\s&lt;em&gt;=\s&lt;/em&gt;(.*)/&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;$1
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;else&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;nil
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;end }.compact untracked=&lt;code&gt;git ls-files --others
--exclude-standard --directory&lt;/code&gt;.split(&quot;\n&quot;) paths.each do |p|
next unless untracked[p]&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;`git clean -df #{p}`
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;end end&lt;/p&gt;
&lt;p&gt;Although I have to admit I'm worried it would be a bit too
fragile, but then again, maybe not.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-02-05T18:59:04+00:00</created-at>
      <creator-id type="integer">27076</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">66</number>
      <permalink>add-git-clean-to-prevent-sub-module-detritus</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8716</project-id>
      <state>open</state>
      <tag>git patch</tag>
      <title>add git-clean to prevent sub-module detritus</title>
      <updated-at type="datetime">2009-02-05T18:59:07+00:00</updated-at>
      <user-id type="integer">27076</user-id>
      <user-name>Darrell Fuhriman</user-name>
      <creator-name>Darrell Fuhriman</creator-name>
      <url>http://capistrano.lighthouseapp.com/projects/8716/tickets/66</url>
      <assigned-user-name>Jamis Buck</assigned-user-name>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">15202</assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>apparently, I should have wrapped that code.  Sorry.

@@@
if :git_enable_submodules == true
  paths=`git whatchanged -m -p .gitmodules`.map{ |l| 
  if l =~ /^-\s+path\s*=\s*(.*)/
    $1
  else 
    nil
  end
  }.compact
  untracked=`git ls-files --others --exclude-standard --directory`.split(&quot;\n&quot;)
  paths.each do |p|
    next if untracked[p]
    `git clean -df #{p}`
  end
end
@@@</body>
      <body-html>&lt;div&gt;&lt;p&gt;apparently, I should have wrapped that code. Sorry.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
if :git_enable_submodules == true
  paths=`git whatchanged -m -p .gitmodules`.map{ |l| 
  if l =~ /^-\s+path\s*=\s*(.*)/
    $1
  else 
    nil
  end
  }.compact
  untracked=`git ls-files --others --exclude-standard --directory`.split(&amp;quot;\n&amp;quot;)
  paths.each do |p|
    next if untracked[p]
    `git clean -df #{p}`
  end
end
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-02-05T19:04:13+00:00</created-at>
      <creator-id type="integer">27076</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">66</number>
      <permalink>add-git-clean-to-prevent-sub-module-detritus</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8716</project-id>
      <state>open</state>
      <tag>git patch</tag>
      <title>add git-clean to prevent sub-module detritus</title>
      <updated-at type="datetime">2009-02-05T19:04:18+00:00</updated-at>
      <user-id type="integer">27076</user-id>
      <user-name>Darrell Fuhriman</user-name>
      <creator-name>Darrell Fuhriman</creator-name>
      <url>http://capistrano.lighthouseapp.com/projects/8716/tickets/66</url>
      <assigned-user-name>Jamis Buck</assigned-user-name>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">15202</assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>And further, I should post the version with the right logic.  *sigh*  Time for more coffee...
@@@
if :git_enable_submodules
  paths=`git whatchanged -m -p .gitmodules`.map{ |l| 
  if l =~ /^-\s+path\s*=\s*(.*)/
    $1
  else 
    nil
  end
  }.compact
  untracked=`git ls-files --others --exclude-standard --directory`.split(&quot;\n&quot;)
  paths.each do |p|
    next unless untracked[p]
    `git clean -df #{p}`
  end
end
@@@</body>
      <body-html>&lt;div&gt;&lt;p&gt;And further, I should post the version with the right logic.
&lt;em&gt;sigh&lt;/em&gt; Time for more coffee...&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
if :git_enable_submodules
  paths=`git whatchanged -m -p .gitmodules`.map{ |l| 
  if l =~ /^-\s+path\s*=\s*(.*)/
    $1
  else 
    nil
  end
  }.compact
  untracked=`git ls-files --others --exclude-standard --directory`.split(&amp;quot;\n&amp;quot;)
  paths.each do |p|
    next unless untracked[p]
    `git clean -df #{p}`
  end
end
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-02-05T19:19:25+00:00</created-at>
      <creator-id type="integer">27076</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">66</number>
      <permalink>add-git-clean-to-prevent-sub-module-detritus</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8716</project-id>
      <state>open</state>
      <tag>git patch</tag>
      <title>add git-clean to prevent sub-module detritus</title>
      <updated-at type="datetime">2009-02-05T19:19:29+00:00</updated-at>
      <user-id type="integer">27076</user-id>
      <user-name>Darrell Fuhriman</user-name>
      <creator-name>Darrell Fuhriman</creator-name>
      <url>http://capistrano.lighthouseapp.com/projects/8716/tickets/66</url>
      <assigned-user-name>Jamis Buck</assigned-user-name>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer" nil="true"></assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>How would people like this ticket to be handled, it looks like a consensus was reached here and this can be closed as [invalid]?</body>
      <body-html>&lt;div&gt;&lt;p&gt;How would people like this ticket to be handled, it looks like a
consensus was reached here and this can be closed as &lt;a href=
&quot;/projects/8716/changesets/invalid&quot; title=
&quot;Changeset [invalid]&quot;&gt;[invalid]&lt;/a&gt;?&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-08-04T10:20:51+01:00</created-at>
      <creator-id type="integer">27076</creator-id>
      <diffable-attributes type="yaml">--- 
:state: open
:assigned_user: 15202
</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">66</number>
      <permalink>add-git-clean-to-prevent-sub-module-detritus</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8716</project-id>
      <state>hold</state>
      <tag>git patch</tag>
      <title>add git-clean to prevent sub-module detritus</title>
      <updated-at type="datetime">2009-08-04T10:20:56+01:00</updated-at>
      <user-id type="integer">1379</user-id>
      <user-name>Lee Hambley</user-name>
      <creator-name>Darrell Fuhriman</creator-name>
      <url>http://capistrano.lighthouseapp.com/projects/8716/tickets/66</url>
      <assigned-user-name nil="true"></assigned-user-name>
    </version>
  </versions>
  <attachments type="array">
    <attachment type="Attachment">
      <code>15593373592d038ce5d4b2fd5951b1161634b9f1</code>
      <content-type>text/plain</content-type>
      <created-at type="datetime">2009-01-21T00:16:22+00:00</created-at>
      <filename>git_clean.patch</filename>
      <height type="integer" nil="true"></height>
      <id type="integer">80286</id>
      <size type="integer">638</size>
      <uploader-id type="integer">27076</uploader-id>
      <width type="integer" nil="true"></width>
      <url>http://capistrano.lighthouseapp.com/attachments/80286/git_clean.patch</url>
    </attachment>
  </attachments>
</ticket>
