Skip to content
This repository was archived by the owner on Nov 27, 2020. It is now read-only.

bin/vendors: break if a bundle has local modifications #232

Merged
merged 1 commit into from
Dec 7, 2011

Conversation

meonkeys
Copy link
Contributor

@meonkeys meonkeys commented Nov 9, 2011

I'm often developing several Symfony2 bundles at once. I have them all
set up as deps for a single Symfony2 application, and I point Netbeans
at the base of the Symfony2 directory.

Since each [sub]dir in vendor/ is a complete git repository, after
making a bunch of changes I can then dive into each dir and commit/push
as necessary.

If I accidentally run "bin/vendors install" while I have un-pushed
changes, they're blown away by the "git reset --hard" in bin/vendors.
This patch proposes to make the script more cautious, assuming that
local modifications should never be blown away. Note that "--force" is
unimplemented, this is just one idea.

Also see my recent post about same to the symfony-devs mailing list.

I'm often developing several Symfony2 bundles at once. I have them all
set up as deps for a single Symfony2 application, and I point Netbeans
at the base of the Symfony2 directory.

Since each [sub]dir in vendor/ is a complete git repository, after
making a bunch of changes I can then dive into each dir and commit/push
as necessary.

If I accidentally run "bin/vendors install" while I have un-pushed
changes, they're blown away by the "git reset --hard" in bin/vendors.
This patch proposes to make the script more cautious, assuming that
local modifications should never be blown away. Note that "--force" is
unimplemented, this is just one idea.
@Problematic
Copy link

I'm -1 on this; I feel like bin/vendors should never contain user modifications, and so I WANT any changes that have crept in to be blown away. Any time I've been tempted to write hacky code as a shortcut, this deters me and forces me to find a cleaner way to handle things :)

In development, I usually point the autoloader to a local path on my machine where I'm making changes (you can even pass it an array if you have some production bundles and some in development within the same namespace, though you have to be careful with this because odd things can and do happen). Then I can easily isolate my work (into a new Netbeans project, for example), commit at will, and not be at risk of losing work from a rogue php bin/vendors install call.

@meonkeys
Copy link
Contributor Author

I like your autoloader suggestion! I'll give that a shot.

@meonkeys
Copy link
Contributor Author

@fabpot
Copy link
Member

fabpot commented Dec 7, 2011

I'm going to merge it as many people have actually lost work because of this.

fabpot added a commit that referenced this pull request Dec 7, 2011
Commits
-------

29dd189 bin/vendors: break if a bundle has local modifications

Discussion
----------

bin/vendors: break if a bundle has local modifications

I'm often developing several Symfony2 bundles at once. I have them all
set up as deps for a single Symfony2 application, and I point Netbeans
at the base of the Symfony2 directory.

Since each [sub]dir in vendor/ is a complete git repository, after
making a bunch of changes I can then dive into each dir and commit/push
as necessary.

If I accidentally run "bin/vendors install" while I have un-pushed
changes, they're blown away by the "git reset --hard" in bin/vendors.
This patch proposes to make the script more cautious, assuming that
local modifications should never be blown away. Note that "--force" is
unimplemented, this is just one idea.

Also see my recent post about same to the symfony-devs mailing list.

---------------------------------------------------------------------------

by Problematic at 2011/11/11 12:33:11 -0800

I'm -1 on this; I feel like bin/vendors should never contain user modifications, and so I WANT any changes that have crept in to be blown away. Any time I've been tempted to write hacky code as a shortcut, this deters me and forces me to find a cleaner way to handle things :)

In development, I usually point the autoloader to a local path on my machine where I'm making changes (you can even pass it an array if you have some production bundles and some in development within the same namespace, though you have to be careful with this because odd things can and do happen). Then I can easily isolate my work (into a new Netbeans project, for example), commit at will, and not be at risk of losing work from a rogue `php bin/vendors install` call.

---------------------------------------------------------------------------

by meonkeys at 2011/11/11 20:23:29 -0800

I like your autoloader suggestion! I'll give that a shot.

---------------------------------------------------------------------------

by meonkeys at 2011/11/17 13:03:45 -0800

See also: <https://groups.google.com/d/msg/symfony-devs/bd8uu5khdeI/kFCuexhibfIJ>
@fabpot fabpot merged commit 29dd189 into symfony:2.0 Dec 7, 2011
@vicb
Copy link
Contributor

vicb commented Dec 7, 2011

Just for information (this happened to me several time) you can recover your modif using git reflog when they were commited.

@stof
Copy link
Member

stof commented Dec 7, 2011

@vicb if they were committed, they are not concerned by this patch as they would not appear in git status

@meonkeys
Copy link
Contributor Author

meonkeys commented Dec 7, 2011

@stof: right, but committed work will be blown away by the git reset --hard. Luckily, as @vicb mentioned, you can use the reflog in that case to retrieve it.

I wasn't sure how to easily/robustly figure out if there were un-pushed changes, so I left that out of the patch. And I had used the reflog safety net to retrieve commits in that case, too.

@pkruithof
Copy link

I can't install a new Symfony project anymore due to this change. When I run bin/vendors install --reinstall, eventually I'll run into this:

> Installing/Updating JMSSecurityExtraBundle
Cloning into '/opt/local/apache2/htdocs/getgeo/vendor//bundles/JMS/SecurityExtraBundle'...
remote: Counting objects: 1676, done.
remote: Compressing objects: 100% (728/728), done.
remote: Total 1676 (delta 889), reused 1598 (delta 811)
Receiving objects: 100% (1676/1676), 273.98 KiB | 233 KiB/s, done.
Resolving deltas: 100% (889/889), done.
 M Resources/meta/LICENSE
 M Security/Authorization/Expression/Ast/NotExpression.php
 M Security/Authorization/Expression/Compiler/NotExpressionCompiler.php
 M Tests/Security/Acl/Expression/HasPermissionFunctionCompilerTest.php
 M Tests/Security/Acl/Expression/PermissionEvaluatorTest.php
 M phpunit.xml.dist
"JMSSecurityExtraBundle" has local modifications. Please revert or commit/push them before running this command again.

Since I start without a vendor folder, it's obvious I didn't make any changes. So I did a git diff to see what's changed, and it seems that the changes are in whitespace. The only thing I can think of is some setting in my git config that does this, but even when I remove the apply and core sections here, the problem remains.

I also tried a git reset --hard HEAD and git clean -df, and then the vendor script, but that didn't solve it either.

@vicb
Copy link
Contributor

vicb commented Feb 7, 2012

check the github help for the whitespace issue

@meonkeys
Copy link
Contributor Author

meonkeys commented Feb 7, 2012

(this is not in reply to vicb)

For more help managing many custom bundles in one app, see: https://groups.google.com/d/msg/symfony-devs/VHJoi1tvzqE/lWVi93cdlOkJ

It's a tiny Bash script that may help you avoid having to manually recover commits after running "bin/vendors install" with unpushed changes in one or more bundles.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants