You can also refer to a revision as an SWH time and place, time being a timestamp of when we
collected it (or as close to the timestamp as we can provide), place being an origin, and
diff --git a/swh/web/ui/tests/views/test_browse.py b/swh/web/ui/tests/views/test_browse.py
--- a/swh/web/ui/tests/views/test_browse.py
+++ b/swh/web/ui/tests/views/test_browse.py
@@ -76,26 +76,26 @@
origin_url='http://cool/project/url'))
@istest
- def search_directory_dir_sha1_only(self):
+ def search_directory_dir_sha1(self):
# when
rv = self.client.get('/directory/search/?sha1_git=some_sha1'
+ '&path=some/path/in/folder'
'&meaningless_arg=gandalf')
# then
self.assertRedirects(rv, url_for('browse_directory',
- sha1_git='some_sha1'))
+ sha1_git='some_sha1',
+ path='some/path/in/folder'))
@istest
- def search_directory_dir_sha1(self):
+ def search_directory_dir_sha1_nopath(self):
# when
rv = self.client.get('/directory/search/?sha1_git=some_sha1'
- '&path=some/path/in/folder'
'&meaningless_arg=gandalf')
# then
self.assertRedirects(rv, url_for('browse_directory',
- sha1_git='some_sha1',
- path='some/path/in/folder'))
+ sha1_git='some_sha1'))
@istest
def search_directory_rev_sha1(self):
@@ -107,7 +107,18 @@
# then
self.assertRedirects(rv, url_for('browse_revision_directory',
sha1_git='some_sha1',
- path='some/path/in/folder'))
+ dir_path='some/path/in/folder'))
+
+ @istest
+ def search_directory_rev_sha1_nopath(self):
+ # when
+ rv = self.client.get('/directory/search/?sha1_git=some_sha1'
+ '&dir_path='
+ '&meaningless_arg=gandalf')
+
+ # then
+ self.assertRedirects(rv, url_for('browse_revision_directory',
+ sha1_git='some_sha1'))
@istest
def search_directory_dir_time_place(self):
diff --git a/swh/web/ui/views/browse.py b/swh/web/ui/views/browse.py
--- a/swh/web/ui/views/browse.py
+++ b/swh/web/ui/views/browse.py
@@ -36,9 +36,13 @@
if sha1_git:
path = data.get('path')
if 'dir_path' in data:
+ dir_path = data.get('dir_path')
+ if dir_path:
+ return redirect(url_for('browse_revision_directory',
+ sha1_git=sha1_git,
+ dir_path=dir_path))
return redirect(url_for('browse_revision_directory',
- sha1_git=sha1_git,
- path=data.get('dir_path')))
+ sha1_git=sha1_git))
if path:
return redirect(url_for('browse_directory',
sha1_git=sha1_git,
@@ -548,14 +552,14 @@
@app.route('/browse/revision/
/directory/')
-@app.route('/browse/revision//directory//')
-def browse_revision_directory(sha1_git, path=None):
+@app.route('/browse/revision//directory//')
+def browse_revision_directory(sha1_git, dir_path=None):
"""Browse directory from revision with sha1_git.
"""
env = {
'sha1_git': sha1_git,
- 'path': '.' if not path else path,
+ 'path': '.' if not dir_path else dir_path,
'message': None,
'result': None
}
@@ -568,7 +572,7 @@
return render_template('revision-directory.html', **env)
try:
- result = api.api_revision_directory(sha1_git, path, with_data=True)
+ result = api.api_revision_directory(sha1_git, dir_path, with_data=True)
result['content'] = utils.prepare_data_for_view(result['content'],
encoding=encoding)
env['revision'] = result['revision']