venmo / synx

A command-line tool that reorganizes your Xcode project folder to match your Xcode groups
MIT License
6.08k stars 274 forks source link

Breaks git after running #64

Open Mark2xv opened 9 years ago

Mark2xv commented 9 years ago

After running synx, the .git folder seems to get destroyed. It is still there, but git does not recognize it as such. I do not get any error messages during the run.

This is a rough distribution of our product, as seen in XCode:

touchapp/   (This is the project file)
    a.bundle
    b.bundle

    Localizable.strings/
        LanguageA.strings (Base)
        LanguageB.strings
        LanguageC.strings

    Images/
        (Just a bunch of images)

    touch/
        Images.xcassets (Launch images, application icons and whatnot)
        SomeGroupWithSomeCode/
            code.h
            code.m
            SubgroupWithSomeMoreCode/
                subcode.h
                subcode.m
        SomeGroupWithSomeMoreCode/
             morecode.h
             morecode.m

    Libraries/
        (A number of git submodules, but also some none libraries and some other external code files)
        (Some have their own .xcodeproj, some have subprojects of their own as well)
    Frameworks/
    Products/

This is roughly how it is reflected in filesystem:

touchapp/
    .git/
    .gitignore
    .gitmodules
    touch.xcodeproj/
    touch/
        LibraryA/
            LibraryA.xcodeproj/
            somecodefromlibrary.h
            somecodefromlibrary.m
        LibraryB/
            (Basically the same as Library A)
        LibraryC/
            libraryheaders.h
            somecode.c
        LanguageA.lproj/
            Localizable.strings
        LanguageB.lproj/
            Localizable.strings
        LanguageC.lproj/
            Localizable.strings
    Images/
    Inline Icons/
    CodeFromExternalParty/
        somecode.h
        somecode.m
    Animation/
    image1.png
    image2.png (and so on for about 50 times)
marklarr commented 9 years ago

After running synx, the .git folder seems to get destroyed. It is still there, but git does not recognize it as such.

What does this mean exactly? What makes it seem like it was destroyed? What is not working?

Mark2xv commented 9 years ago

The folder is still there, but git does not recognize it as a repository.

Steps taken:

synx /Users/mark/touch/touch.xcodeproj

Wait for it to finish.. Finishes without any errors.

Afterwards, check git status:

fatal: Not a git repository (or any of the parent directories): .git

I'll check tomorrow what's actually changing in the .git directory to try and figure out what's changing.

marklarr commented 9 years ago

That's weird... does it look like anything is missing from .git?

Mark2xv commented 9 years ago

Yes, some things are definitely missing.

A diff -r touch/.git backupSynxedGit shows this:

Only in touch/.git: FETCH_HEAD
Only in touch/.git: HEAD
Only in touch/.git: config
Only in touch/.git: index
Only in touch/.git/logs: HEAD

and a whole lot more such as the contents of .git/modules.

I also spotted this in the output of synx:

Syncing files that are not included in Xcode project..
  Localizable.strings/
    .git
      COMMIT_EDITMSG
      config
      FETCH_HEAD
      HEAD
      index
      logs
        HEAD
        refs
          heads
            develop
            feature
              -featurenameredacted-
              -featurenameredacted-
            hotfix
              2.5.5
            master
          remotes
            origin
              feature
                -featurenameredacted-
                -featurenameredacted-
              HEAD
              hotfix
                2.5.5
      modules
        touch

And basically the entire contents of .git. Why is it putting it as if it's 'under' Localizable.strings? It is most surely not located there.

Mark2xv commented 9 years ago

Why not just completely ignore any directory called .git and any file called .gitmodules or .gitignore? I can't think of any circumstance where you would want to change the location of those.

marklarr commented 9 years ago

Synx creates another directory in a temporary location on your computer, builds the synced up version of your project there, and then moves it over to replace the original. So, because it works this way, synx can't just ignore things like .git -- it needs to bring them over to the synced up version.

I've never heard of this issue before, so I'm assuming that there is something unique with the way your project is setup. Mostly people's .git directory lives alongside their project directory. IE,

└── YourClonedRepo
    ├── .git
    ├── YourProject

It seems like yours is more like

└── YourProject
    ├── .git

which is why Synx needs to tamper with the .git directory.

As far as why it's not moving your .git directory correctly, I'm not sure. It doesn't seem like it should be treating it any differently than any other directory. It's hard to diagnose without having the project.

Mark2xv commented 9 years ago

For a number of reasons I can't show you the project, and absolutely under no circumstance share the files themselves. What would you need to try and figure out what's going on?

kylef commented 9 years ago

@Mark2xv Would you be able to create a similar project which can be used to reproduce the issues? Steps to reproduce, or an example project you can run with Synx to reproduce would help figuring out the problem.

marklarr commented 9 years ago

what @kylef said

Mark2xv commented 9 years ago

Alright, I'll see if I can recreate the same scenario.

marklarr commented 9 years ago

@Mark2xv any luck?

Mark2xv commented 9 years ago

Haven't really had the chance to investigate/reproduce this issue as of yet. I'll try to do so this weekend.

Mark2xv commented 9 years ago

Having a really hard time figuring out what is the cause of this is... None of my reproduction cases seem to have any effect.

On a sidenote: I noticed that in another issue (#65) that the -e option does not do what I thought it does. Not that it has/had any effect though, including exclusion options or not, it still seems to delete roughly 2/3rds of my folders contents. (Goes from 550MB to 200MB).

Is there no way of making sure it absolutely ignores any folder that is a submodule? So that it completely copies it over, exactly as it was, to the newly synced folder?

nunogoncalves commented 9 years ago

I have the same issue. I'm still trying to figure this one out and came here to see if anybody as the same problem.

Mark2xv commented 9 years ago

I haven't had much time lately to try and figure out what's causing all of this. Unfortunately, I can not give any more information regarding our project structure either...

I really hope this issue will get solved as this would save a lot of time!

jonzhan commented 8 years ago

Managed to get this to reproduce reliably, after a particularly terrifying afternoon.

Works with XCode Version 7.2 (7C68)

  1. Create a new project (I used the template for iOS Single View Application)
  2. Make it into a git repo
  3. Create a storyboard file in the project
  4. Remove the storyboard file reference from XCode
  5. Move the storyboard file into a subfolder at the same level as the .xcodeproj (the name does not appear to matter. I got this bug because I had a storyboard in a "Base.lproj" folder but the bug can be reproduced with a name like "Potato" as well
  6. Drag the storyboard file back into XCode, and don't copy it
  7. git status --> A-OK 👌
  8. synx projectname.xcodeproj
  9. git status --> EVERYTHING BURNS 🌏🔥🔥🔥🔥🔥🔥💀💀💀💀💀💀

@nunogoncalves @Mark2xv I guess it's been a long time since you guys have had this problem, but just FYI it seemed to work for me after this: I moved the offending files out of the project structure, removed references in XCode, then dragged them into the project and let xcode put them wherever it wants.

nunogoncalves commented 8 years ago

Thanks for the info @jonzhan . On a company project I was doing also had translations (therefor the Base.lproj folder). In that project I always remove the .git files before I run synx. This is dangerous because it's not automated, and I guess it's just a matter of time before I make a wrong copy paste and have to checkout the whole project all over again :)

kumamotone commented 8 years ago

I am facing the same problem. I tried the code of https://github.com/venmo/synx/pull/104 but I couldn't resolve the problem.

Damnum commented 8 years ago

Any news on this? I'm having the same problem

MattMorgis commented 7 years ago

Is this project still maintained? This is still an issue.

noordawod commented 7 years ago

Burned up my .git directory as well 👎 In the log I can definitely see synx handling .git folder. Why on earth should it do that? I think all hidden directories (aka, starts with a .) should be ignored.

Plus, the Pods directory...

Well, there should be an option to let me decide which directories to ignore altogether -- not just only an option to ignore groups.

noordawod commented 7 years ago

Since I don't know Ruby, I opted to fix these issues using a shell script. You can grab a copy here:

https://gist.github.com/noordawod/ea1a5fc1fb5654fcba509f6e5862a4eb