Search Unity

Git support on Package Manager

Discussion in 'Package Manager' started by rizu, Oct 24, 2018.

  1. spaceemotion

    spaceemotion

    Joined:
    Sep 29, 2015
    Posts:
    77
  2. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    320
    That was discussed in another thread. You should raise your voice there too

    https://forum.unity.com/threads/custom-package-with-git-dependencies.628390/
     
    Last edited: Jan 6, 2020
  3. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,025
    ok so without using external plugins, is not possible to use git url as dependencies inside a package.
     
  4. starikcetin

    starikcetin

    Joined:
    Dec 7, 2017
    Posts:
    268
    sebas77 likes this.
  5. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,025
    OK Currently I chose to use OpenUPM as solution.
     
  6. jon_levin

    jon_levin

    Joined:
    Nov 24, 2019
    Posts:
    3
    I would really like to define a non-root git package (specifically to publish a Unity project git repo, with the package containing only the Asset directory).

    I saw this mentioned earlier in the thread but didn't find a follow-up.
    I thought GitHub packages could be a workaround for this, but couldn't get Unity to play nice with them.

    I feel like this is a really strong use case for existing code / new code that should include examples (my use case).
    Is support for this planned any time soon?
     
  7. Johannski

    Johannski

    Joined:
    Jan 25, 2014
    Posts:
    617
    You can use the git subtree split command, like described here: https://www.patreon.com/posts/25070968

    I decided for the sake of simplicity to not include the complete project, but just the relevant folder in the git repo. This of course means, that you need to create a project on your own before including the package, but also makes it really easy to include the repo as a submodule, cuts right to the case and does not have any unity version changes and so on. If you need an example setup for that, take a look at https://github.com/supyrb/signals
     
  8. maximeb_unity

    maximeb_unity

    Unity Technologies

    Joined:
    Mar 20, 2018
    Posts:
    161
    We're currently working on adding support for packages stored in a sub-directory of the Git repository, opening up the possibility to use Git-based dependencies with repos tracking multiple packages. This is not available yet, but should be available in 2020.1.
     
  9. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    320
    @maximeb_unity Will it use git feature like sparse checkout?

    Or unity need to invent new approach?
     
  10. maximeb_unity

    maximeb_unity

    Unity Technologies

    Joined:
    Mar 20, 2018
    Posts:
    161
    Sparse checkout is basically an optimization, and it's been around for a long time now, so this might be used as part of the feature, if possible and relevant. (Then again, sparse checkout does more than that and is useful for more complex flows than merely checking out.)
     
    Last edited: Jan 14, 2020
    Thaina likes this.
  11. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    320
    Actually I would like to make a request that, git package in manifest and dependency should be pulled with the git system. And, importantly, upm should unlock the pulled package folder so we could edit and commit package with the git command

    So if the UPM would developed to be more align with git system (such as, just using sparse checkout with the included package), it would be more likely that my request will be more possible to do

    What I hope is, when we include any package into our project with git, we could also edit and develop that package in the same time as developing the project, instead of having project for develop package separated from the actual project, and we could also commit the package with just git and don't need to switch back and forth between local and git in the manifest. We could just use git in package local folder and still share project for other people in the team
     
  12. maximeb_unity

    maximeb_unity

    Unity Technologies

    Joined:
    Mar 20, 2018
    Posts:
    161
    I understand that what you are looking for is a (legitimately!) better workflow and tools for developing a package, and a simpler way of switching back and forth between "development mode" and regular consumption. This is definitely something that we're looking into - but as you might know by now I don't have an ETA I can share for that yet.

    Even though such a feature would presumably use Git (and perhaps even other VCS backends), the current Git-based feature will not be changed as it serves a different purpose and use case than the one you describe. That is, while the current Git-based dependency feature uses a remote Git repository as the source of a package, it then filters out files the same way that the package would be distributed, which should normally be identical to a packed version of the repository files. A pure Git clone of the repository located in the project would result in something different (such as files that aren't necessary for consumers of the package), but also files that are very much needed for a developer or maintainer of the package (such as the .git directory!) Both features are complementary and fulfill different use cases.

    Thank you for the feedback and suggestions!
     
    Thaina likes this.
  13. spaceemotion

    spaceemotion

    Joined:
    Sep 29, 2015
    Posts:
    77
    You can already kind of do that with git submodules. You just need to update one copy and pull in all the others.
     
  14. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    320
    In the current workflow, whenever you try to edit anything that was pulled from UPM, it will often got overridden and lose. And you can't easily commit it to git. For developing package you need to have separate project. Which is not practical

    Imagine you have working on large project. You have separate some utility into separate package then include it back into your project and working with your team. Then your team found a bug in that package. Then the whole process are broken, you need to switch your package manifest url to your local, pull it into project, fix it, push it, switch back, etc, etc, etc, etc. The current workflow is totally annoying. If you really have did it you would understand so, please.

    Just try to explain to you make me recall the frustration so please
     
    Last edited: Jan 15, 2020
  15. spaceemotion

    spaceemotion

    Joined:
    Sep 29, 2015
    Posts:
    77
    We're doing the exact workflow as I described above (submodules) and there is no manifest change required so unity does not actually update or overwrite our code from new pulls. Updating the package is now as easy as pulling in the latest changes. Only for AssetStore publishing we open up the standalone project.
     
    maximeb_unity likes this.
  16. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    320
    That is the point you misunderstand

    The thing I suggest is that you don't require to pull latest change because the latest change would be developed in the project directly. Only the package consumer in other project or developer in other machine will need to pull it. But you who would be both the package developer and project developer won't need, the package can be seemlessly developed at the same time as the project

    We are currently talking about UPM git package, not the asset store package
     
  17. spaceemotion

    spaceemotion

    Joined:
    Sep 29, 2015
    Posts:
    77
    Not really following here as that's exactly what this allows us. Yes, the updates on other machines are not automatically done by Unity, but we're using git anyways and updating submodules just comes with a normal project pull in that case.

    1. Dev A works on a feature in a package (submodule), commits and pushes it. This updates the commit hash reference for git
    2. Dev B pulls the project, package updates automatically.
    3. Dev B works on a fix in the package, pushes it
    4. Dev A pulls, got latest changes from Dev B

    All of our UAS packages are also UPM packages (in private repos)
     
  18. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    320
    This is the point. By your workaround you just don't use UPM in your main project anymore. That's what I request it to change. We should use UPM everywhere in unity and just make it work with git directly. And then you just come to push your workaround without understanding the point. I try not to say this but please stop man

    I can workaround in anything, we can workaround in everything, but that's not a practical solution. Practical solution is unity should just adopt it as official feature

    This declare your total misunderstand about UPM

    UPM may be look like asset store package with the same folder structure and capability. But unlike asset store package, it not included directly into your asset folder. It just stay outside and just being linked into project. And so we could develop it in separate folder and separate git repo, it don't related to the project repo and don't event need to setup the submodule. Just import it into manifest and then just worked
     
  19. spaceemotion

    spaceemotion

    Joined:
    Sep 29, 2015
    Posts:
    77
    Sorry if I came across as too harsh, I was just trying to suggest an alternative, until this feature could be implemented.

    Please correct me if I am wrong, but as far as I understand it:
    - "Assets" has your project's content
    - "Library" contains all cached files as well as the downloaded packages (via the Package cache)
    - "Packages" contains the manifest and potential custom packages.

    How would you expect the suggested workflow to work when you hit "Reimport All"? If they open up the possibility to edit packages, I'd guess all your changes would be lost as the Library folder gets dropped.

    If I'm still getting it wrong, sorry.
     
    Last edited: Jan 15, 2020
  20. brunocoimbra

    brunocoimbra

    Joined:
    Sep 2, 2015
    Posts:
    60
    While I do agree with @Thaina that this would be a very helpful and desired feature, the alternative until that is real which achieves the exact same result is what @spaceemotion suggested, which is to use git submodules where both read and write is needed and leave UPM only for external read-only resources.

    I do that with different projects using the same package. Found a bug? Fix it, commit the submodule and then my team will receive the updated package once they pull the latest changes of the project. Later when I am gonna work on a different project using that same package I just pull the changes on the submodule and everything is fine.
     
  21. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    320
    My point is
    - UPM will pull the package into Library/PackageCache
    - - Which might cause some problem to edit it because it might got overridden by reimport
    - AssetStore package will pull your package directly into asset folder
    - - Which means it mess around with your project folder and repo

    I think you get my point already so, for your question, I would be preferred that "Reimport All" will not drop the PackageCache folder but just pull all package from the git source into latest version instead. And if I have edit any file in any package it would just be normally merged or become a git conflict that I could also handle conflict normally
     
  22. konsic

    konsic

    Joined:
    Oct 19, 2015
    Posts:
    961
    In manifest file json there is dependency asset required. How do I download dependency so that is placed in required folder inside Unity project?
     
unityunity