Page 1 of 2 12 LastLast
Results 1 to 25 of 35

Thread: Auto Updater and Git

  1. #1
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,778
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

    Default Auto Updater and Git

    [/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
    Code:
    git init
    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)
    Code:
    git add new.txt
    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
    Last edited by Shuttleu; 05-17-2012 at 11:36 PM.

  2. #2
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,778
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

  3. #3
    Join Date
    Oct 2011
    Location
    UK
    Posts
    1,322
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    Thanks for doing this we could probably get rid of my tutorial as getting everybody using git would be great

  4. #4
    Join Date
    Nov 2011
    Posts
    1,589
    Mentioned
    9 Post(s)
    Quoted
    17 Post(s)

    Default

    Hey when I do the Git Init in CMD i get this

    Any ideas?
    Mat



    ^^

  5. #5
    Join Date
    May 2007
    Location
    England/Liverpool
    Posts
    1,004
    Mentioned
    9 Post(s)
    Quoted
    106 Post(s)

    Default

    Quote Originally Posted by Aligndude View Post
    Hey when I do the Git Init in CMD i get this

    Any ideas?
    Mat
    yeah you need to use git's bash command prompt

  6. #6
    Join Date
    Nov 2011
    Posts
    1,589
    Mentioned
    9 Post(s)
    Quoted
    17 Post(s)

    Default

    Quote Originally Posted by CRU1Z1N View Post
    yeah you need to use git's bash command prompt
    How am I ment to do the remote add origin ? it doesn't work
    Mat



    ^^

  7. #7
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,778
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

    Default

    Quote Originally Posted by Aligndude View Post
    Hey when I do the Git Init in CMD i get this

    Any ideas?
    Mat
    you didnt choose the middle option "Run Git from the Windows Command
    Prompt" when installing git

    so you can either run it from the git bash, or reinstall git but choose the middle option

    the video shows it
    Quote Originally Posted by Aligndude View Post
    How am I ment to do the remote add origin ? it doesn't work
    Mat
    run this
    Code:
    git remote add origin https://{username}@code.google.com/p/{project}/
    but replace {username} with your google account username and {project} with your projects name

    ~shut

  8. #8
    Join Date
    May 2007
    Location
    England/Liverpool
    Posts
    1,004
    Mentioned
    9 Post(s)
    Quoted
    106 Post(s)

    Default

    worked perfect for me great tut as it is
    just this line

    Simba Code:
    else writeLn('You have the latest version of the script!');

  9. #9
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,778
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

    Default

    Quote Originally Posted by CRU1Z1N View Post
    worked perfect for me great tut as it is
    just this line

    Simba Code:
    else writeLn('You have the latest version of the script!');
    Thanks, I think I found that in the video, but I must have forgot to remove it on here

    ~shut

  10. #10
    Join Date
    Dec 2006
    Location
    Program TEXAS home of AUTOERS
    Posts
    7,934
    Mentioned
    26 Post(s)
    Quoted
    237 Post(s)

    Default

    Shuttleu, why is my local rep shown like this:
    "git clone https://Pinky%40grandecom.net@code.g...pinky-scripts/ "

    guessing that is the reason why it won't work anymore for me:
    To https://pinky%40grandecom.net@code.g...pinky-scripts/
    ! [rejected] master -> master (non-fast-forward)
    error: failed to push some refs to 'https://pinky%40grandecom.net@code.google.com
    /p/pinky-scripts/'
    To prevent you from losing history, non-fast-forward updates were rejected
    Merge the remote changes (e.g. 'git pull') before pushing again. See the
    'Note about fast-forwards' section of 'git push --help' for details.

  11. #11
    Join Date
    Dec 2006
    Location
    Sweden
    Posts
    10,812
    Mentioned
    3 Post(s)
    Quoted
    16 Post(s)

    Default

    Your username shouldn't have an @ in it. ^

    Also all that code is mine, I do not appreciate you ripping it all off as your own. Please add credits at least. And you removed my important failsafe of
    if (Length(trim(OnlineVersion)) <> 3) then


    Send SMS messages using Simba
    Please do not send me a PM asking for help; I will not be able to help you! Post in a relevant thread or make your own! And always remember to search first!

  12. #12
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,778
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

    Default

    Quote Originally Posted by P1nky View Post
    Shuttleu, why is my local rep shown like this:
    "git clone https://Pinky%40grandecom.net@code.g...pinky-scripts/ "

    guessing that is the reason why it won't work anymore for me:
    it seems your git repo was modified modified on somewhere other than the folder you set up

    run "git pull"
    then try "git push origin master" again

    ~shut

  13. #13
    Join Date
    Dec 2006
    Location
    Program TEXAS home of AUTOERS
    Posts
    7,934
    Mentioned
    26 Post(s)
    Quoted
    237 Post(s)

    Default

    Quote Originally Posted by Harry View Post
    Your username shouldn't have an @ in it. ^

    Also all that code is mine, I do not appreciate you ripping it all off as your own. Please add credits at least. And you removed my important failsafe of
    I see, and what you mean the code? are you referring to me or Shuttleu?

  14. #14
    Join Date
    Dec 2006
    Location
    Sweden
    Posts
    10,812
    Mentioned
    3 Post(s)
    Quoted
    16 Post(s)

    Default

    Referring to Shuttleu.


    Send SMS messages using Simba
    Please do not send me a PM asking for help; I will not be able to help you! Post in a relevant thread or make your own! And always remember to search first!

  15. #15
    Join Date
    Dec 2006
    Location
    Program TEXAS home of AUTOERS
    Posts
    7,934
    Mentioned
    26 Post(s)
    Quoted
    237 Post(s)

    Default

    Quote Originally Posted by Shuttleu View Post
    it seems your git repo was modified modified on somewhere other than the folder you set up

    run "git pull"
    then try "git push origin master" again

    ~shut
    Shuttleu, I just tried it out and same error, should I make a new Gmail?
    Quote Originally Posted by Harry View Post
    Referring to Shuttleu.
    Oh okay

  16. #16
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,778
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

    Default

    Quote Originally Posted by Harry View Post
    Your username shouldn't have an @ in it. ^

    Also all that code is mine, I do not appreciate you ripping it all off as your own. Please add credits at least. And you removed my important failsafe of
    sorry, i thought i left the credits in there

    also i removed the <> and replaced it with a > so if the local version was higher than the remote version (for testing purposes) then it wouldnt try and re-download the script

    ~shut

  17. #17
    Join Date
    Dec 2006
    Location
    Sweden
    Posts
    10,812
    Mentioned
    3 Post(s)
    Quoted
    16 Post(s)

    Default

    OK, just the point of that failsafe is if the page returns a 404/other invalid request, it will say that error.


    Send SMS messages using Simba
    Please do not send me a PM asking for help; I will not be able to help you! Post in a relevant thread or make your own! And always remember to search first!

  18. #18
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,778
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

  19. #19
    Join Date
    Jan 2012
    Posts
    32
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Code:
    Checking for script updates...
    2.1
    
    2.0
    Newer script version online!
    Autoupdating to newer version.
    ReWriteFile - Exception. Could not create file: C:\Users\$$$$\Downloads\Ogre_Destroyer_V2.1
    _By:baja_blast1.simba
    Fatal error writing to C:\Users\$$$$\Downloads\Ogre_Destroyer_V2.1
    _By:baja_blast1.simba!!
    Successfully executed.
    This keeps happening, happen to anyone else or anyone have a fix?

  20. #20
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,778
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

    Default

    Quote Originally Posted by baja_blast1 View Post
    Code:
    Checking for script updates...
    2.1
    
    2.0
    Newer script version online!
    Autoupdating to newer version.
    ReWriteFile - Exception. Could not create file: C:\Users\$$$$\Downloads\Ogre_Destroyer_V2.1
    _By:baja_blast1.simba
    Fatal error writing to C:\Users\$$$$\Downloads\Ogre_Destroyer_V2.1
    _By:baja_blast1.simba!!
    Successfully executed.
    This keeps happening, happen to anyone else or anyone have a fix?
    this is completely off topic, post it in the scripts thread

    ~shut

  21. #21
    Join Date
    Dec 2006
    Location
    Sweden
    Posts
    10,812
    Mentioned
    3 Post(s)
    Quoted
    16 Post(s)

    Default

    Look at his name shuttleu

    It looks to me like the version number you have on server is older than client's version.


    Send SMS messages using Simba
    Please do not send me a PM asking for help; I will not be able to help you! Post in a relevant thread or make your own! And always remember to search first!

  22. #22
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,778
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

    Default

    Quote Originally Posted by Harry View Post
    Look at his name shuttleu

    It looks to me like the version number you have on server is older than client's version.
    whoops, didnt notice that

    anyway, it seems the problem isnt that, it is having problems writing the file, meaning either he doesnt have admin rights, or the file name is not allowed

    ~shut

  23. #23
    Join Date
    Jan 2012
    Posts
    32
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks for the tut, I ended up getting it to work.

  24. #24
    Join Date
    Jan 2012
    Posts
    1,104
    Mentioned
    18 Post(s)
    Quoted
    211 Post(s)

    Default

    Thanks for this, I will switch to git!

  25. #25
    Join Date
    Jan 2012
    Posts
    1,104
    Mentioned
    18 Post(s)
    Quoted
    211 Post(s)

    Default

    I need help please.
    Simba Code:
    procedure AutoUpdateMe;
    var NewFile : Integer;
        OnlineVersion, NewScript, NewFileName : String;
    begin
      if UseAutoChecker then
      begin
        writeln('Checking for script updates...');
        OnlineVersion := GetPage('https://hunt3rx3-git.googlecode.com/git/chaosmosskiller_version.txt');
        writeln(OnlineVersion);
        writeln(ScriptVersion);
        TerminateScript;
      end;
    end;
    I get this in debug:
    Code:
    Checking for script updates...
    
    2.0
    Successfully executed.
    This means, it wont read the webpage, wont write anything into the string. Any ideas?
    EDIT: Solved problem. GetPage doesnt work with 'https://'. Had to use 'http://'.
    Last edited by Shatterhand; 02-21-2012 at 07:03 PM.

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •