Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kranc should output its directory and branch when it runs #43

Open
ianhinder opened this issue Dec 13, 2011 · 1 comment
Open

Kranc should output its directory and branch when it runs #43

ianhinder opened this issue Dec 13, 2011 · 1 comment

Comments

@ianhinder
Copy link
Owner

Kranc should output its directory and branch when it runs. This should go to the screen, and probably also to the generated thorn's README or a small source file. This may help prevent surprises if people accidentally run the wrong version.

(Requested by Erik Schnetter in https://trac.einsteintoolkit.org/ticket/698)

@barrywardell
Copy link
Collaborator

I use the following piece of code to achieve this for another Mathematica package. It first checks for BUILD_ID and GIT_REVISION files (which are included in releases), and then falls back to detecting these manually.

KrancVersion[] :=
Module[{path, buildid, gitrev},
path = FileNameDrop[FindFile["Kranc`"], -2];

buildid = Quiet@ReadList[FileNameJoin[{path, "BUILD_ID"}], "String"];
If[SameQ[buildid, $Failed],
buildid = "git";
,
buildid = First[buildid];
];

gitrev = Quiet@ReadList[FileNameJoin[{path, "GIT_REVISION"}],"String"];
If[SameQ[gitrev, $Failed],
gitrev = First@ReadList["!git --git-dir "<>FileNameJoin[{path, ".git"}]<>" rev-parse HEAD", String];
,
gitrev = First[gitrev];
];

Grid[{{"Installed in:", path},
{"Build ID: ", buildid},
{"Git revision: ", gitrev}},
Alignment -> Left]
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants