[/COLOR]Using git for managing your scripts and a autoupdater
Hello, in this tutorial i will show you how you can use git to control your scripts and keep them updated
for this tutorial i will use GooleCode simply because it supports git and you do not need SSL in order to access the raw files
Introduction
Okay so what is git?
Git is a version control system, it allows you to host a project or some files and allows you to update them, but it can also revert those changes and give you diffs
Using this we can keep track of our scripts, easily update them and see what we done between each version
Also if you use this from the very start, you can go back to the very first version of a script even if you dont have it any more
Video tutorial: http://www.youtube.com/watch?v=zZAgfQt5tiQ
Git
Okay, so how do we do this? Simple, just follow the instruction below
right one thing which we need to install first is git, you can get this here http://git-scm.com/download
Once this has downloaded install it with all the default settings with the exception of choosing "Run Git from the Windows Command
Prompt"
For this example my projects will be "shuttleu-simba-scripts"
Now we need to go to http://code.google.com/hosting/createProject and sign in (if you havent already signed in)
Put a project name, example, description and for "Version Control System" choose git.
For "Source Code License" choose "GNU GPL v3" (i have no idea of the differences but just choose this anyway)
and put some labels in, then click "Create project"
Now you will be taken to the "Project home". Click "Source", then in the first blue box, choose the link that says "googlecode.com password.".
Scroll half way down and tick the box that says "Accept account@gmail.com Google Account password when using a Git or Mercurial client" under "Security"
Now create a directory and call it and call it something relating to your repo.
Next open Command prompt (or terminal) and cd to the new directory.
eg.
Code:
cd c:/Users/YourName/Desktop/shuttleu-simba-scripts
Next we initialize the directory to be used with git, so we type
and then we need to add the remote location to the foldet so it knows where the remote location is
Code:
git remote add origin https://shuttleu:password@code.google.com/p/shuttleu-simba-scripts/
Right now this is set up we need to add some files. Create a new file in the folder and call it "new.txt"
now to upload the files you just do three commands (you will easily remember them over time)
this adds the file to be submitted allowing you to leave certain files out if you dont want them updated
Code:
git commit -m "a message here"
this puts all the files together ready to be submitted to remote location. Think of it as a package, when you run this it puts them
all in a package waiting for the postman to collect it to send it off. You can run this several times before the next command which
will act as several commits.
Code:
git push origin master
this sends the files off to the remote location
Now it should say something like the following
Counting objects: 3, done.
Writing objects: 100% (3/3), 207 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: Scanning pack: 100% (3/3), done.
remote: Storing objects: 100% (3/3), done.
remote: Processing commits: 100% (1/1), done.
To
https://shuttleu:password@code.googl...simba-scripts/
* [new branch] master -> master
now, go to http://code.google.com/p/shuttleu-si...source/browse/ (replace it with your project name) and you should see the
file
Congratulations, you have set up git correctly
Let me know if any of this didnt make sense.
Auto Updating
Now because GoogleCode doesnt require SSL, we can use it for auto updating our scripts
In your script create a constant which will hold the script version
Simba Code:
const
ScriptVersion = '1.0';
UseAutoChecker = true;
now one more thing, we need to create a version file, create a new file in the scripts folder and call it "LatestVersion.txt"
and upload this to git
next we need to create the function which will check and update the script
Simba Code:
//Please note that almost all of this code was written by Harry, i just edited it a bit
procedure AutoUpdateMe;
var Neifile:integer;
OnlineVersion, NewScript, NeiFeilNennen:string;
begin
if UseAutoChecker then
begin
writeln('Checking for script updates...');
OnlineVersion := GetPage('http://shuttleu-simba-scripts.googlecode.com/git/LatestVersion.txt');
writeln(OnlineVersion);
writeln(ScriptVersion)
if (trim(OnlineVersion) > ScriptVersion) then
begin
writeLn('Newer script version online!');
writeLn('Autoupdating to newer version.');
NewScript := GetPage('http://shuttleu-simba-scripts.googlecode.com/git/TheScript.simba');
NeiFeilNennen := ScriptPath+ 'ScriptName V'+OnlineVersion+' by User.simba';
Neifile := Rewritefile(NeiFeilNennen, true);
try
WriteFileString(Neifile, NewScript);
except
begin
writeLn('Fatal error writing to '+NeiFeilNennen+'!!');
terminatescript;
end;
end;
CloseFile(Neifile);
writeLn('New script downloaded to '+NeiFeilNennen+'!! Please use this one!!');
TerminateScript;
end else
writeLn('You have the latest version of the script!');
end else
WriteLn('!!!!! Not checking for latest version, you may be outdated!');
end;
and run this on script startup
I know this tutorial is incomplete, but i will get round to fixing it up, however it should be enough to get some people set up
Testing branch
You can have a testing branch for all your changes, this means you can put your script in a testing branch for people to test before you actually release the script, giving you enough time to squeeze out all the bugs
http://villavu.com/forum/showthread.php?t=82621
~shut