Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/simplify-current-hash'
Browse files Browse the repository at this point in the history
* origin/simplify-current-hash:
  Simplify how "current_hash" is determined for installed packages
  • Loading branch information
jsiwek committed Jul 17, 2019
2 parents 4c87e8e + 52aa529 commit 5b8c3cb
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 20 deletions.
8 changes: 8 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@

2.0.1-2 | 2019-07-17 10:44:50 -0700

* Simplify how "current_hash" is determined for installed packages (Jon Siwek, Corelight)

For packages installed via version tag, this will also change the
meaning of "current_hash" from being the hexsha of the tag object itself
to the hexsha of the commit object pointed to by the tag.

2.0.1 | 2019-07-09 10:37:20 -0700

* Release 2.0.1.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.1
2.0.1-2
2 changes: 1 addition & 1 deletion doc/man/zkg.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" Man page generated from reStructuredText.
.
.TH "ZKG" "1" "Jul 09, 2019" "2.0.1" "Zeek Package Manager"
.TH "ZKG" "1" "Jul 17, 2019" "2.0.1-2" "Zeek Package Manager"
.SH NAME
zkg \- Zeek Package Manager
.
Expand Down
2 changes: 1 addition & 1 deletion zeekpkg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import logging

__version__ = "2.0.1"
__version__ = "2.0.1-2"
__all__ = ['manager', 'package', 'source']

LOG = logging.getLogger(__name__)
Expand Down
18 changes: 1 addition & 17 deletions zeekpkg/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2173,8 +2173,8 @@ def _install(self, package, version, use_existing_clone=False):
status.tracking_method = TRACKING_METHOD_BRANCH

status.current_version = version
status.current_hash = _get_hash(clone, version, status.tracking_method)
_git_checkout(clone, version)
status.current_hash = clone.head.object.hexsha
status.is_outdated = _is_clone_outdated(
clone, version, status.tracking_method)

Expand Down Expand Up @@ -2250,15 +2250,6 @@ def _get_branch_names(clone):
return rval


def _get_ref(clone, ref_name, track_method):
for ref in clone.refs:
if ((track_method == TRACKING_METHOD_BRANCH and
'origin' in ref.name and
ref.name.split('origin/')[1] == ref_name) or
ref.name.split('/')[-1] == ref_name):
return ref


def _is_version_outdated(clone, version):
version_tags = _get_version_tags(clone)
latest = _normalize_version_tag(version_tags[-1])
Expand All @@ -2282,13 +2273,6 @@ def _is_clone_outdated(clone, ref_name, tracking_method):
raise NotImplementedError


def _get_hash(clone, version, track_method):
if track_method == TRACKING_METHOD_COMMIT:
return clone.commit(version).hexsha

return _get_ref(clone, version, track_method).object.hexsha


def _is_commit_hash(clone, text):
try:
commit = clone.commit(text)
Expand Down

0 comments on commit 5b8c3cb

Please sign in to comment.