Library Version Control

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
DeltaF1
Citizen
Posts: 64
Joined: Mon Apr 27, 2015 4:12 pm
Location: The Bottom of the Stack
Contact:

Library Version Control

Post by DeltaF1 »

I want to pose a question to all the other lovers out there about using personal libraries.

I've built and use a set of libraries and utilities for my own personal use, ranging from vector math to some basic gui elements. Every time I make an update to the tools, I have to manually copy and paste the code into all of my other projects that might benefit from that new feature.

What have you lovers used as solutions to this problem? How do you manage code shared between projects?
User avatar
Evine
Citizen
Posts: 72
Joined: Wed May 28, 2014 11:46 pm

Re: Library Version Control

Post by Evine »

Fewer love project. As I'm doing live code reloading and error handling it has gotten easier to simply work with just a single love file.

But thinking about it, it might be a good idea to have a common library folder on your computer that you just used Lua own loadfile() function to call the library. Or a more fancy: check date on library --> copy/paste into project folder --> load , this way the love file will always be releasable.
Artal, A .PSD loader: https://github.com/EvineDev/Artal
bobbyjones
Party member
Posts: 730
Joined: Sat Apr 26, 2014 7:46 pm

Re: Library Version Control

Post by bobbyjones »

DeltaF1 why not design a solution? That's the fun in knowing a programming language. With lua and github or other host you definitely design a system. Or maybe even more homemade you can do it only using lua and luafilesystem and a list of the love projects. Let's your imagination run rampant.
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: Library Version Control

Post by Positive07 »

bobbyjones wrote:--What Bobby said--
TOTALLY! You should create a script that automates this for you, either by creating something similar to luarocks (loverocks maybe more similar to what you would like) but local or by creating a loader for require that uses io ([manual]5.7[/manual]) to get a library from you libraries folder, then you can use [manual]loadstring[/manual] to load the file... that would simply be great solution too, but as Bobby said let your imagination go rampant (and upload it to github so that w can all enjoy :awesome: )
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: Library Version Control

Post by s-ol »

I just use symlinks, but only for the stuff I am working on right now. If I kept updating my old pojects I'd end up breaking something at some point.

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
User avatar
DeltaF1
Citizen
Posts: 64
Joined: Mon Apr 27, 2015 4:12 pm
Location: The Bottom of the Stack
Contact:

Re: Library Version Control

Post by DeltaF1 »

Thanks for all the replies!

Evine: I'm working on a networked game atm, so I have 2 projects, one for the client, and one for the server, and they need to share functionalities.

bobbyjones, Positive07: I'll probably end up doing that. Maybe rewrite require to search for a local copy of the file, and then look in the shared library directory if it can't find it? Also I wrote some simple batch scripts to zip and rename to .love, maybe that script could also copy the required libraries into the .love?

S0lll0s: I have to share code between my server and client projects atm, but I would not want to update code in my really old projects, I agree.
User avatar
Inny
Party member
Posts: 652
Joined: Fri Jan 30, 2009 3:41 am
Location: New York

Re: Library Version Control

Post by Inny »

Its a bad idea to automatically update core dependencies without performing testing. Having a script to copy it between projects is a great idea, but leave in that hook that makes you test it and not that it broke something (like you rearranged the parameters to a function and that caused a crash).
bobbyjones
Party member
Posts: 730
Joined: Sat Apr 26, 2014 7:46 pm

Re: Library Version Control

Post by bobbyjones »

An easy solution is to have unit testing for every project. That way after every automatic update you automatically run unit test if it fails it remains the same as before and notifies you if it maybe.
alloyed
Citizen
Posts: 80
Joined: Thu May 28, 2015 8:45 pm
Contact:

Re: Library Version Control

Post by alloyed »

Since I use already use git on all my projects, I'd probably just end up using git submodules instead of symlinks or a full-on package manager.
basic workflow:

Code: Select all

~/my-game $ git submodule add ~/my-lib my-lib && git submodule init # install my-lib to my-game
~/my-lib $ git commit -m "Made a change" # update my-lib
~/my-game $ git submodule foreach git pull origin master # pull update from my-lib, and any other libs into my-game
~/my-game $ git commit -m "updated our copy of my-lib"
it's not exactly automatic but it does mean you keep control of when updates happen, you can roll back updates if they break old games, and you don't really need to keep a stable API or version your libraries
User avatar
ejmr
Party member
Posts: 302
Joined: Fri Jun 01, 2012 7:45 am
Location: South Carolina, U.S.A.
Contact:

Re: Library Version Control

Post by ejmr »

alloyed wrote:

Code: Select all

~/my-game $ git submodule foreach git pull origin master
Alternatively I think you get the same effect with this:

Code: Select all

$ git submodule update --remote
A trivial improvement as far as "number of keys you have to press" is concerned. But if you ever have submodules that either pull from somewhere besides "origin" or that you want checked-out on a branch besides "master", or both, then personnaly I think 'git submodule update --remote' is more convenient.

Just a small tip I wanted to mention.
ejmr :: Programming and Game-Dev Blog, GitHub
南無妙法蓮華經
Post Reply

Who is online

Users browsing this forum: No registered users and 174 guests