Forum: Ruby on Rails Git and vendor/rails

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Colin L. (Guest)
on 2009-03-28 14:03
(Received via mailing list)
This is really a git question but the problem is with rails using git
and
others may have come across the problem.

I have a branch on my application's git repository with edge rails as a
subproject checked out into vendor/rails. this allows me to keep my
application edge-compliant by checking out the branch (which creates the
rails folder in vendor), pulling the latest edge rails and running my
tests.  This works fine.

The problem comes when I checkout the master again (which does not have
a
vendor/rails folder). Git removes the contents of vendor/rails but
leaves an
empty rails folder. The application will not run, the empty rails folder
confuses it, so I have to manually delete the folder.  Obviously I can
have
a simple script to solve the problem but I wonder if there is a way of
telling git to remove the empty folder. Or perhaps there is an
alternative.
I have googled in vain.

Any ideas?

Colin
Bosko I. (Guest)
on 2009-03-28 15:47
(Received via mailing list)
I think you will not be able make git to do it. Git tracks content not
files and folders and it will not delete folder. You can use post-
checkout hook to do that for you.

Regards,
Bosko
Colin L. (Guest)
on 2009-03-28 17:29
(Received via mailing list)
2009/3/28 Bosko I. <removed_email_address@domain.invalid>

>
> I think you will not be able make git to do it. Git tracks content not
> files and folders and it will not delete folder. You can use post-
> checkout hook to do that for you.
>
>
Yes, of course.  I have not used hooks previously.  For anyone that is
interested all I had to do is make a script
 called post-checkout in .git/hooks with the following contents.

#!/bin/sh
# remove vendor/rails directory if not specified in .gitmodules
if [ -d vendor/rails ]
then
  # vendor/rails exists
  if ! grep -s -q vendor/rails .gitmodules
  then
    # vendor/rails not in .gitmodules, remove vendor/rails
    rmdir vendor/rails
  fi
fi

Yes I know this could probably be done much more concisely, but it is
only
the third script I have written so I like to keep it simple and with
comments so that I can understand it.

Colin

Regards,
This topic is locked and can not be replied to.