From 6510d34e812e56eb58132122055036f7b7803c93 Mon Sep 17 00:00:00 2001 From: tkl Date: Tue, 26 Jul 2016 11:44:06 +0200 Subject: [PATCH 1/6] 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:]) + From f303e7a25e596d3ab5df5ac0d4b410ab1c8bef2e Mon Sep 17 00:00:00 2001 From: tkl Date: Tue, 26 Jul 2016 11:56:59 +0200 Subject: [PATCH 2/6] git_commit template --- source/firmware/git_commit.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/firmware/git_commit.h b/source/firmware/git_commit.h index 1004a40..b88f11f 100644 --- a/source/firmware/git_commit.h +++ b/source/firmware/git_commit.h @@ -4,7 +4,7 @@ #define GIT_COMMIT_H #define CURRENT_COMMIT "0" -#define AUTHOR "tkl " #define LOCAL_CHANGES "NO" #define UNTRACKED_FILES "NO" From 916cf510dbfe0d7114f1d14dd09d8211def4221a Mon Sep 17 00:00:00 2001 From: tkl Date: Tue, 26 Jul 2016 11:58:12 +0200 Subject: [PATCH 3/6] wip --- source/firmware/git_commit.h | 1 + 1 file changed, 1 insertion(+) diff --git a/source/firmware/git_commit.h b/source/firmware/git_commit.h index b88f11f..279eb67 100644 --- a/source/firmware/git_commit.h +++ b/source/firmware/git_commit.h @@ -9,3 +9,4 @@ #define UNTRACKED_FILES "NO" #endif /* GIT_COMMIT_H */ + From 172b045fcadd5f0e397b66338748dd465e5ea663 Mon Sep 17 00:00:00 2001 From: tkl Date: Tue, 26 Jul 2016 12:01:47 +0200 Subject: [PATCH 4/6] wip --- source/firmware/git_commit.h | 1 - 1 file changed, 1 deletion(-) diff --git a/source/firmware/git_commit.h b/source/firmware/git_commit.h index 279eb67..b88f11f 100644 --- a/source/firmware/git_commit.h +++ b/source/firmware/git_commit.h @@ -9,4 +9,3 @@ #define UNTRACKED_FILES "NO" #endif /* GIT_COMMIT_H */ - From 9a1d5ed3782d88f126db8a0178945b594bf13ed9 Mon Sep 17 00:00:00 2001 From: tkl Date: Tue, 26 Jul 2016 12:14:45 +0200 Subject: [PATCH 5/6] wip --- source/firmware/git_commit.h | 1 + 1 file changed, 1 insertion(+) diff --git a/source/firmware/git_commit.h b/source/firmware/git_commit.h index b88f11f..279eb67 100644 --- a/source/firmware/git_commit.h +++ b/source/firmware/git_commit.h @@ -9,3 +9,4 @@ #define UNTRACKED_FILES "NO" #endif /* GIT_COMMIT_H */ + From 05df450f8f904118a46fd9d98c98270c92ca4698 Mon Sep 17 00:00:00 2001 From: tkl Date: Tue, 26 Jul 2016 12:16:53 +0200 Subject: [PATCH 6/6] wip --- source/scripts/get_history.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/scripts/get_history.py b/source/scripts/get_history.py index 5b78b0c..86d9533 100755 --- a/source/scripts/get_history.py +++ b/source/scripts/get_history.py @@ -83,7 +83,7 @@ def main(argv): 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) + generate_include_file("source/firmware/git_commit.h", commit_list, local_changes, untracked_files) if __name__ == "__main__": main(argv[1:])