Page MenuHomeSoftware Heritage

browse/snapshot_context: Fix revision_found setting in directory view
ClosedPublic

Authored by anlambert on Mon, Jan 10, 4:40 PM.

Details

Summary

That variable was set in an incorrect way. As revision_id can be None,
it should be initialized to False and set to True after checking the
revision can be found in the archive.

This fixes the non display of the "History" button in the snapshot
directory view when a snapshot contains no revisions.

Related to T3840

Depends on D6898

Diff Detail

Repository
rDWAPPS Web applications
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

vlorentz added a subscriber: vlorentz.
vlorentz added inline comments.
swh/web/browse/snapshot_context.py
829–834

slightly clearer IMO, but either way is fine

This revision is now accepted and ready to land.Mon, Jan 10, 4:44 PM

Build is green

Patch application report for D6899 (id=25016)

Could not rebase; Attempt merge onto b68b37df41...

Updating b68b37df..546924d3
Fast-forward
 swh/web/browse/snapshot_context.py          |  8 +++--
 swh/web/tests/browse/views/test_snapshot.py | 55 ++++++++++++++++++++++++++++-
 2 files changed, 60 insertions(+), 3 deletions(-)
Changes applied before test
commit 546924d301647f9ae68c7586bf4a6431fb80faf9
Author: Antoine Lambert <anlambert@softwareheritage.org>
Date:   Mon Jan 10 16:34:58 2022 +0100

    browse/snapshot_context: Fix revision_found setting in directory view
    
    That variable was set in an incorrect way. As revision_id can be None,
    it should be initialized to False and set to True after checking the
    revision can be found in the archive.
    
    This fixes the non display of the "History" button in the snapshot
    directory view when a snapshot contains no revisions.
    
    Related to T3840

commit 4ddf1b5598dc07bb23f28b29b7f50b3979e906e9
Author: Antoine Lambert <anlambert@softwareheritage.org>
Date:   Mon Jan 10 15:38:39 2022 +0100

    browse/snapshot_context: Handle empty revisions history in log view
    
    It now exists in the archive snapshot containing only releases targeting
    directories (typically those generated by the package loaders).
    
    Thus these snapshots do not contain any revisions, this was leading to a
    server error when trying to browse their history view.
    
    Now a 404 error will be returned when trying to browse the revisions
    history of such snapshots.
    
    Related to T3840

See https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/1281/ for more details.

Build is green

Patch application report for D6899 (id=25017)

Could not rebase; Attempt merge onto b68b37df41...

Updating b68b37df..835a8601
Fast-forward
 swh/web/browse/snapshot_context.py          |  9 +++--
 swh/web/tests/browse/views/test_snapshot.py | 55 ++++++++++++++++++++++++++++-
 2 files changed, 61 insertions(+), 3 deletions(-)
Changes applied before test
commit 835a86012630f83bed0e5b849724c67509263d5f
Author: Antoine Lambert <anlambert@softwareheritage.org>
Date:   Mon Jan 10 16:34:58 2022 +0100

    browse/snapshot_context: Fix revision_found setting in directory view
    
    That variable was set in an incorrect way. As revision_id can be None,
    it should be initialized to False and set to True after checking the
    revision can be found in the archive.
    
    This fixes the non display of the "History" button in the snapshot
    directory view when a snapshot contains no revisions.
    
    Related to T3840

commit 4ddf1b5598dc07bb23f28b29b7f50b3979e906e9
Author: Antoine Lambert <anlambert@softwareheritage.org>
Date:   Mon Jan 10 15:38:39 2022 +0100

    browse/snapshot_context: Handle empty revisions history in log view
    
    It now exists in the archive snapshot containing only releases targeting
    directories (typically those generated by the package loaders).
    
    Thus these snapshots do not contain any revisions, this was leading to a
    server error when trying to browse their history view.
    
    Now a 404 error will be returned when trying to browse the revisions
    history of such snapshots.
    
    Related to T3840

See https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/1282/ for more details.