Skip to content

Commit

Permalink
Update commit handling and JS package version
Browse files Browse the repository at this point in the history
Revised the commit hash determination to ensure it is always recorded, shifting this logic from set_version to export.

NP-349
  • Loading branch information
saumyaj3 committed Oct 10, 2024
1 parent 297614d commit 46edb53
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
4 changes: 2 additions & 2 deletions DulcificumJS/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion DulcificumJS/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ultimaker/dulcificumjs",
"version": "0.1.0-alpha.11",
"version": "0.1.0-alpha.12",
"description": "DulcificumJS is a TS component to run Dulcificum in a browser",
"main": "dist/index.js",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions conandata.yml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
version: "0.2.1"
commit_hash: "unknown"
18 changes: 8 additions & 10 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,8 @@ class DulcificumConan(ConanFile):
"with_apps": False,
"with_python_bindings": True,
}
commit_hash = None

def set_version(self):
try:
git = Git(self)
self.commit_hash = git.get_commit()
except ConanException as e:
self.commit_hash = "unknown"
self.output.error(f"An error occurred: {e}")
if not self.version:
self.version = self.conan_data["version"]

Expand All @@ -71,7 +64,13 @@ def _run_tests(self):
return not self.conf.get("tools.build:skip_test", False, check_type = bool)

def export(self):
update_conandata(self, {"version": self.version})
try:
git = Git(self)
commit_hash = git.get_commit()
except ConanException as e:
commit_hash = "unknown"
self.output.error(f"An error occurred: {e}")
update_conandata(self, {"version": self.version, "commit_hash": commit_hash})

def export_sources(self):
copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder)
Expand Down Expand Up @@ -137,8 +136,7 @@ def generate(self):
tc.variables["ENABLE_TESTS"] = self._run_tests
tc.variables["EXTENSIVE_WARNINGS"] = self.options.enable_extensive_warnings
tc.variables["DULCIFICUM_VERSION"] = self.version
tc.variables["GIT_COMMIT_HASH"] = self.commit_hash

tc.variables["GIT_COMMIT_HASH"] = self.conan_data["commit_hash"]
tc.variables["WITH_APPS"] = self.options.with_apps
if self.options.with_apps:
tc.variables["APP_VERSION"] = self.version
Expand Down

0 comments on commit 46edb53

Please sign in to comment.