likeablePanda 48 Posted June 3, 2021 So, my partner in crime @Hosfad and myself have been giving poor @Hashtag way too much work by basically cutting and pasting from our current giant private github, to the github repo on the SDN. Not ideal as then it can be hard to review, as again, poor @Hashtag let us know. Here's how our project is set up on a private github project/account (dummy project as an example): If we push this as-is to the SDN, my understanding is that all scripts would have to be updated at the same time, even if we only want to update one. Do we have to separate out into a bunch of different modules? Would that not make it so that we have to have a copy of UTILS_FOR_ALL_SCRIPTS in each module? And when we make a change to the utils, we'd have to update each and every single module with the new util folder? If we can avoid that it'd be great, there's a lot of room for human error there! In addition, if possible, we really like the interface github provides, so it'd be nice to connect the github repo to the sdn repo in some meaninful way. We'd love advice on how to refactor this , or just configure our repo with the SDN properly so we don't have to refactor.
Pandemic 2818 Posted June 3, 2021 Hey there, I think the easiest way would be to use multiple git remotes, here's a little guide I found: https://jigarius.com/blog/multiple-git-remote-repositories But basically you'd have both our git repo and Github's as remotes, and when you commit and push your changes, it would go to both places
likeablePanda 48 Author Posted June 3, 2021 1 minute ago, Pandemic said: Hey there, I think the easiest way would be to use multiple git remotes, here's a little guide I found: https://jigarius.com/blog/multiple-git-remote-repositories But basically you'd have both our git repo and Github's as remotes, and when you commit and push your changes, it would go to both places Thank you! that's excellent for having both sdn and our own repo. You went the extra mile and gave us a link The other thing i'm confused about is how to handle those individual scripts, each Main (as in FishingMain,FletchingMain,HerbloreMain) has their own @ScriptManifest. Suppose the Fishing, Herblore, and Fletching scripts are each their own unique scripts, some paid some not. If I commit and push to the SDN, these scripts aren't in different modules. So how do we update only one script at a time, even if we push code that changes multiple scripts?
Pandemic 2818 Posted June 3, 2021 28 minutes ago, likeablePanda said: Thank you! that's excellent for having both sdn and our own repo. You went the extra mile and gave us a link The other thing i'm confused about is how to handle those individual scripts, each Main (as in FishingMain,FletchingMain,HerbloreMain) has their own @ScriptManifest. Suppose the Fishing, Herblore, and Fletching scripts are each their own unique scripts, some paid some not. If I commit and push to the SDN, these scripts aren't in different modules. So how do we update only one script at a time, even if we push code that changes multiple scripts? You can have any number of scripts in the same repo, and when you go to upload them you set the repo (the actual .git part), and the module is the root folder name of the script you want to upload. When we compile it, we only compile that script, not the full repo. Example: mygitrepo.git Fighter/ src/ Fighter.java Herblore/ src/ Herblore.java Then when you'd go to add it to our SDN, you'd put in your repo's name (mygitrepo in this case), and the module name would be the top level folder inside of that repo (either Fighter or Herblore here). Hope that helps!
Hosfad 155 Posted June 3, 2021 3 minutes ago, Pandemic said: You can have any number of scripts in the same repo, and when you go to upload them you set the repo (the actual .git part), and the module is the root folder name of the script you want to upload. When we compile it, we only compile that script, not the full repo. Example: mygitrepo.git Fighter/ src/ Fighter.java Herblore/ src/ Herblore.java Then when you'd go to add it to our SDN, you'd put in your repo's name (mygitrepo in this case), and the module name would be the top level folder inside of that repo (either Fighter or Herblore here). Hope that helps! Thank you so much for the help
likeablePanda 48 Author Posted June 3, 2021 1 hour ago, Pandemic said: When we compile it, we only compile that script, not the full repo. Example: mygitrepo.git Fighter/ src/ Fighter.java Herblore/ src/ Herblore.java So we effectively have a "module", let's call it Utils, that all other modules depend on. mygitrepo.git Fighter/ src/ Fighter.java Herblore/ src/ Herblore.java Utils src/ fancyAntiBan.java whatever.java If we push something like this and set Utils as a dependency of Herblore and a dependency of Fighter (in intellij), will the SDN understand that? is there any way to communicate that dependency otherwise? I'd like to avoid the following: mygitrepo.git Fighter/ src/ Fighter.java Utils/ fancyAntiBan.java whatever.java Herblore/ src/ Herblore.java Utils/ fancyAntiBan.java whatever.java Because if we change utils for one script, we want it to change for *all* scripts Thanks again!
Pandemic 2818 Posted June 3, 2021 12 minutes ago, likeablePanda said: So we effectively have a "module", let's call it Utils, that all other modules depend on. mygitrepo.git Fighter/ src/ Fighter.java Herblore/ src/ Herblore.java Utils src/ fancyAntiBan.java whatever.java If we push something like this and set Utils as a dependency of Herblore and a dependency of Fighter (in intellij), will the SDN understand that? is there any way to communicate that dependency otherwise? I'd like to avoid the following: mygitrepo.git Fighter/ src/ Fighter.java Utils/ fancyAntiBan.java whatever.java Herblore/ src/ Herblore.java Utils/ fancyAntiBan.java whatever.java Because if we change utils for one script, we want it to change for *all* scripts Thanks again! Right now we don't have a very good way of handling that, and we require that you do it the way you say you'd like to avoid We might have better support for shared libraries like that since it's so often used, but as of now you'll have to do it the hard way. Thanks!
Neffarion 486 Posted June 4, 2021 You can use IntelliJ modules to share the source of common functions across scripts. When you compile a script it will join the module and the script
likeablePanda 48 Author Posted June 4, 2021 20 hours ago, Pandemic said: but as of now you'll have to do it the hard way. OVER. MY. DEAD. BODY!!!! I found a solution for my needs. I'll share it here. I refuse to manually manage 10+ util folders! Here's how my folders are now setup ZodiacFighter/ src/ Fighter.java Utils/ fancyAntiBan.java whatever.java ZodiacHerblore/ src/ Herblore.java Utils/ fancyAntiBan.java whatever.java ZodiacUtils src/ Utils/ fancyAntiBan.java whatever.java Notice I have BOTH a utils module AND Util package in each other module. In intellij, tell intellij to "Mark directory as excluded" every Utils folder in every module that isn't the Utils module. Then, I add a hook to the git pre-commit so in ProjectFolder/.git/hook/pre-commit I have the code: #!/usr/bin/env python import argparse import os import shutil def parse_args(): pass def main(args=None): files = os.listdir(os.getcwd()) for file in files: if(os.path.isdir(file)): print("directory " + file); if( not "ZodiacUtils" in file and "Zodiac" in file): print("ZodiacUtils/src/Utils",file+"/src/Utils") shutil.rmtree(file+"/src/Utils"); shutil.copytree("ZodiacUtils/src/Utils",file+"/src/Utils") os.system("git add " + file+"/src/Utils"); pass if __name__ == "__main__": args = parse_args() main(args) This replaces every src/Utils folder that contains the word "Zodiac" with the Utils folder in ZodiacUtils/src/Utils So now whenever you commit, it'll automatically copy those folders and add them to the repo. Note this is NOT a copy paste solution! it'd have to be personalized @Neffarion I wrote this before you posted this proposed solution. If I understand (which I may not), wouldn't this only work locally? Once you push it to the SDN the SDN has no knowledge of the module dependency as @Pandemic said in his previous post in this forum topic. Or am I missing something that'd be simpler than my silly yet effective solution
Recommended Posts
Archived
This topic is now archived and is closed to further replies.