From 6510d34e812e56eb58132122055036f7b7803c93 Mon Sep 17 00:00:00 2001 From: tkl Date: Tue, 26 Jul 2016 11:44:06 +0200 Subject: [PATCH] scripts + template header to determine repository state --- .project | 6 +++ .pydevproject | 5 ++ source/firmware/git_commit.h | 11 +++++ source/scripts/.gitignore | 2 + source/scripts/commit.py | 46 ++++++++++++++++++ source/scripts/get_history.py | 90 +++++++++++++++++++++++++++++++++++ 6 files changed, 160 insertions(+) create mode 100644 .pydevproject create mode 100644 source/firmware/git_commit.h create mode 100644 source/scripts/.gitignore create mode 100644 source/scripts/commit.py create mode 100755 source/scripts/get_history.py diff --git a/.project b/.project index 6605278..abe4261 100755 --- a/.project +++ b/.project @@ -5,6 +5,11 @@ + + org.python.pydev.PyDevBuilder + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder clean,full,incremental, @@ -23,5 +28,6 @@ org.eclipse.cdt.core.ccnature org.eclipse.cdt.managedbuilder.core.managedBuildNature org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + org.python.pydev.pythonNature diff --git a/.pydevproject b/.pydevproject new file mode 100644 index 0000000..40e9f40 --- /dev/null +++ b/.pydevproject @@ -0,0 +1,5 @@ + + +Default +python 2.7 + diff --git a/source/firmware/git_commit.h b/source/firmware/git_commit.h new file mode 100644 index 0000000..1004a40 --- /dev/null +++ b/source/firmware/git_commit.h @@ -0,0 +1,11 @@ +/* Generated include file */ + +#ifndef GIT_COMMIT_H +#define GIT_COMMIT_H + +#define CURRENT_COMMIT "0" +#define AUTHOR "tkl 0: + git_commit.append(line) + ret.append(commit(git_commit)) + return ret + +def generate_include_file(file_name, commit_list, local_changes, untracked_files): + if(len(commit_list) > 0): + f = open(file_name, "w") + f.write("/* Generated include file */\n\n") + f.write("#ifndef GIT_COMMIT_H\n") + f.write("#define GIT_COMMIT_H\n\n") + f.write("#define CURRENT_COMMIT\t") + f.write("\"" + commit_list[0].hash() + "\"\n") + f.write("#define AUTHOR\t\t") + f.write("\"" + commit_list[0].author() + "\"\n") + f.write("#define LOCAL_CHANGES\t") + if(local_changes): + f.write("\"YES\"\n") + else: + f.write("\"NO\"\n") + f.write("#define UNTRACKED_FILES\t") + if(untracked_files): + f.write("\"YES\"\n") + else: + f.write("\"NO\"\n") + f.write("\n#endif /* GIT_COMMIT_H */\n") + f.close() + +def main(argv): + local_changes = check_for_changes() + untracked_files = check_for_untracked() + log_list = get_git_log() + commit_list = get_commit_list(log_list) + generate_include_file("../firmware/git_commit.h", commit_list, local_changes, untracked_files) + +if __name__ == "__main__": + main(argv[1:]) +