generated from ShadowMario/FNF-PsychEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
175 additions
and
104 deletions.
There are no files selected for viewing
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
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package funkin.backend.macro; | ||
|
||
#if macro | ||
import sys.io.Process; | ||
#end | ||
|
||
class GitMacro | ||
{ | ||
/** | ||
Current git commit number. | ||
**/ | ||
public static var commitNumber(get, never):Int; | ||
|
||
/** | ||
Current git commit hash. | ||
**/ | ||
public static var commitHash(get, never):String; | ||
|
||
/** | ||
Current git branch. | ||
**/ | ||
public static var branch(get, never):String; | ||
|
||
@:noCompletion private static function get_branch() | ||
return _currentBranch(); | ||
|
||
@:noCompletion private static function get_commitNumber() | ||
return _commitNumber(); | ||
|
||
@:noCompletion private static function get_commitHash() | ||
return _commitHash(); | ||
|
||
@:noCompletion private static macro function _commitNumber() | ||
{ | ||
#if display | ||
return macro $v{0}; | ||
#else | ||
try | ||
{ | ||
final process = new Process('git', ['rev-list', 'HEAD', '--count'], false); | ||
process.exitCode(true); | ||
|
||
return macro $v{Std.parseInt(process.stdout.readLine())}; | ||
} | ||
catch (e) | ||
{ | ||
trace("Error Gettings Hash from Git" + e); | ||
} | ||
return macro $v{0} #end | ||
} | ||
|
||
@:noCompletion private static macro function _commitHash() | ||
{ | ||
#if display | ||
return macro $v{"~"}; | ||
#else | ||
try | ||
{ | ||
final process = new Process('git', ['rev-parse', '--short', 'HEAD'], false); | ||
process.exitCode(true); | ||
|
||
return macro $v{process.stdout.readLine()}; | ||
} | ||
catch (e) | ||
{ | ||
trace("Error Gettings Hash from Git" + e); | ||
} | ||
return macro $v{"~"} #end | ||
} | ||
|
||
@:noCompletion private static macro function _currentBranch() | ||
{ | ||
#if display | ||
return macro $v{""}; | ||
#else | ||
try | ||
{ | ||
final process = new Process("git", ["rev-parse", "--abbrev-ref", "HEAD"], false); | ||
process.exitCode(true); | ||
|
||
return macro $v{process.stdout.readLine()}; | ||
} | ||
catch (e) | ||
{ | ||
trace("Error Gettings Hash from Git" + e); | ||
} | ||
return macro $v{""} #end | ||
} | ||
} |
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
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
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