Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage of git submodules #3

Open
jugendhacker opened this issue Nov 7, 2021 · 21 comments
Open

Usage of git submodules #3

jugendhacker opened this issue Nov 7, 2021 · 21 comments

Comments

@jugendhacker
Copy link

As the current status with the dependency repos is pretty much complicated (especially for F-Droid), I would suggest to use git submodules to fix specific versions of the dependency repos that should be pulled for build the app or at least state in the repo which exact tag is needed to build a version of Gravity Play, so we could use sourcelibs on the F-Droid side.

@bagaturchess
Copy link
Collaborator

bagaturchess commented Nov 11, 2021

Hi and sorry for the delay!

I have to learn more about git submodules ...

For now, I would propose to use not head but 100 tags of all libs. They will not change. I will always keep versions 100 up to date with the latest stable release for F-Droid.

This means we should replace these 4 links:
https://github.com/MetatransApps/Android_LIB_Commons
https://github.com/MetatransApps/Android_LIB_CommonsAds
https://github.com/MetatransApps/Android_LIB_Commons2D
https://github.com/MetatransApps/Android_APP_2DGravity
with
https://github.com/MetatransApps/Android_LIB_Commons/releases/tag/100
https://github.com/MetatransApps/Android_LIB_CommonsAds/releases/tag/100
https://github.com/MetatransApps/Android_LIB_Commons2D/releases/tag/100
https://github.com/MetatransApps/Android_APP_2DGravity/releases/tag/100
I hope this solves the issue with small changes for both sides?

Best regards,
Krasimir

@jugendhacker
Copy link
Author

This would not really solve it, because you still can't build it really reproducible. If I then want to build an old version I won't know which version of the libs to select. I would really suggest you to take a look on git submodules because it fits really good here.

@bagaturchess
Copy link
Collaborator

bagaturchess commented Nov 13, 2021

Hi,

this "7.11 Git Tools - Submodules
Submodules
It often happens that while working on one project, you need to use another project from within it. Perhaps it’s a library that a third party developed or that you’re developing separately and using in multiple parent projects. A common issue arises in these scenarios: you want to be able to treat the two projects as separate yet still be able to use one from within the other."
looks very good! :-)

Here it has even better explanation: https://docs.gitlab.com/ee/ci/git_submodules.html

Thanks for this recommendation and hint!

I will implement it, hopefully soon ... then I will update you here.

Best regards,
Krasimir

@bagaturchess
Copy link
Collaborator

bagaturchess commented Nov 13, 2021

Hi I have created this file: https://github.com/MetatransApps/Android_APK_2DGravity/blob/master/.gitmodules
According to my understanding, this should be enough from git perspective?
Please let me know what are the next steps to proceed with F-Droid update of Gravity game?
Best regards,
Krasimir

@jugendhacker
Copy link
Author

This did not quite work. Better use the git submodule command to set them up instead of manually creating the submodules file. For more information on it consider the documentation

@MetatransApps
Copy link
Owner

MetatransApps commented Nov 28, 2021

Hi and sorry for the delay.
Thanks for the link. This is the first time I use git submodules ... ;-)
I made it via the console with git commands.
Is it ok now and how to refer released versions/tags of the dependencies? (currently it points to the master branches)
Best regards,
Krasimir

@jugendhacker
Copy link
Author

You have to change into the folder of the submodule and type git checkout tagName, currently tagName could be 100 for example. Then change back into top folder and add & commit the changes.

@MetatransApps
Copy link
Owner

MetatransApps commented Nov 29, 2021

Hi, I made these changes.
Hopefully in a correct way?
I have done this for all 4 dependencies but only one line was finally changed to "Subproject commit 82406cbdd9c151193ae7f053ef7b4fa90786887b" in Android_LIB_Commons dependency.
0dbe259

I am not sure whether this is correct.

@jugendhacker
Copy link
Author

Seems like you only added commit to Android_LIB_Commons after the 100 tag

@MetatransApps
Copy link
Owner

Hi,

this is what I tried for 1 dependency (Android_LIB_CommonsAds):
C:\AndroidStudio\workspace\Android_APK_2DGravity\Android_LIB_CommonsAds>git checkout 100
HEAD is now at 051266d Cosmetic change
C:\AndroidStudio\workspace\Android_APK_2DGravity\Android_LIB_CommonsAds>git add *

C:\AndroidStudio\workspace\Android_APK_2DGravity\Android_LIB_CommonsAds>

but then I don't see any changes in GitHub Desktop app ...

Best regards,
Krasimir

@jugendhacker
Copy link
Author

You need to cd .. and then git add

@MetatransApps
Copy link
Owner

MetatransApps commented Nov 30, 2021

I do "cd ..." as well, but still nothing appears in my desktop app as change ...

I am stuck here. ;-(

@jugendhacker
Copy link
Author

It does not change anything, because you did not commit anything after tag 100 in all dependencies except Android_LIB_Commons

@MetatransApps
Copy link
Owner

Hi and thanks for the reply!
Interesting, I have never thought about this during my tries to make it working ...
So, now I have to push one change in the rest 3 repos and than to repeat the exercise, right?
Best regards,
Krasimir

@jugendhacker
Copy link
Author

You actually use the submodules like git repos. But the version you checked out will be noted inside the parent repo. By that you are able to pin those submodules to a specific version when you release a new version/tag, so that if someone builds the app off a specific tag (like we do over at F-Droid), they will get the same result as you building it during the release.

@MetatransApps
Copy link
Owner

MetatransApps commented Dec 15, 2021

To be honest, it was a big mess on my side, regarding versioning, before uploading everything to git. I made it a few months ago, when starting to work with F-Droid.
So, thanks! :-)
I have beginner level of git understanding. I hope I understand the concept and the differences in git, as I am used to other version control systems (e.g. SVN, Perforce).

Do I need to create new release with this 'git checkout 100' command included?

@jugendhacker
Copy link
Author

jugendhacker commented Mar 9, 2022

Sorry for letting you wait that long, seems like I have missed your reply.

Do I need to create new release with this 'git checkout 100' command included?

Yes that would be the best option and please also do the same with your other apps.

@MetatransApps
Copy link
Owner

MetatransApps commented Mar 10, 2022

Hi, no worries, I forgot everything I have done with git submodules but now I will remember the right way and will do it from scratch for all games. :-)
I have create this new repo, with the same content and once we are done we will do the same for the original repo. It is public so you could check and verify at the end, whether it is correctly implemented:
https://github.com/MetatransApps/Android_APK_2DGravity_submodules
Best regards,
Krasimir

@MetatransApps
Copy link
Owner

MetatransApps commented Mar 10, 2022

Hm, what about the gradle scripts I have now. Will they work the same way after I made this changes with submodules? Maybe they also have to be changed. The gradle files are auto generated from Android Studio. When we are done with the submodules, I will connect Android Studio with git and I assume it will recognize submodules and will regenerate the gradle script, so hopefully this will not be an issue.

@MetatransApps
Copy link
Owner

MetatransApps commented Mar 10, 2022

Hi @jugendhacker jugendhacker,
here are all changes, which are necessary from my perspective.
Could you please verify this repo:
https://github.com/MetatransApps/Android_APK_2DGravity_submodules
If it is ok I will do the same for the original repo.
Best regards,
Krasimir

UPDATE1: I have added one last commit to this test repo.

UPDATE2: Here is my script which do it:

cd Android_APK_2DGravity_submodules

git submodule add https://github.com/MetatransApps/Android_LIB_Commons
git submodule add https://github.com/MetatransApps/Android_LIB_CommonsAds
git submodule add https://github.com/MetatransApps/Android_LIB_Commons2D
git submodule add https://github.com/MetatransApps/Android_APP_2DGravity

  1. Push in each submodule a minor change (e.g. create new history.txt file or update it)

  2. git submodule update --remote --merge

cd Android_LIB_Commons
git checkout v101
cd ..
cd Android_LIB_CommonsAds
git checkout v101
cd ..
cd Android_LIB_Commons2D
git checkout v101
cd ..
cd Android_APP_2DGravity
git checkout v101
cd ..

  1. git add *

  2. push changes of Android_APK_2DGravity_submodules to main

@MetatransApps
Copy link
Owner

MetatransApps commented Nov 2, 2022

Hi there,

I am very happy to share that the new version 110 of the Gravity game is now available on F-Droid!
https://f-droid.org/en/packages/com.gravityplay/

Best regards,
Krasimir

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

No branches or pull requests

3 participants