Created
March 10, 2010 18:21
-
-
Save mataspetrikas/328160 to your computer and use it in GitHub Desktop.
Extracting git information in ActionScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.soundcloud.utils { | |
import flash.utils.ByteArray; | |
/** | |
* @author Matas Petrikas (SoundCloud) [email protected] | |
* | |
* extract latest Git revision number for later use in AS3 | |
* based on SVNUtil class by Apt labs: | |
* http://labs.apt.no/2009/11/20/automatically-embedding-a-subversion-revision-number/ | |
* | |
* Use: | |
* public static const VERSION:String = GitUtils.version; | |
* or directly trace(GitUtils.version) | |
*/ | |
public class GitUtils { | |
// note, that you might need to adjust this path, depending on your project folder structure | |
[Embed(source="../../../../.git/refs/heads/master", mimeType="application/octet-stream")] | |
private static var _entriesByteArray : Class; | |
public static function get version() : String { | |
var entries : String = readEntries(40); | |
return entries; | |
} | |
private static function readEntries(length : uint) : String { | |
return (new _entriesByteArray() as ByteArray).readUTFBytes(length); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment