Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[23.1] Minor fix to enable external hgweb process #18256

Merged
merged 2 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/galaxy/config/sample/tool_shed.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ tool_shed:
# installation directory.
#hgweb_config_dir: null

# Default URL prefix for repositories served via hgweb. If running an
# external hgweb server you should set this to an empty string.
#hgweb_repo_prefix: repos/

# Where Tool Shed repositories are stored.
#file_path: database/community_files

Expand Down
8 changes: 8 additions & 0 deletions lib/galaxy/config/schemas/tool_shed_config_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ mapping:
Where the hgweb.config file is stored.
The default is the Galaxy installation directory.

hgweb_repo_prefix:
type: str
required: false
default: repos/
desc: |
Default URL prefix for repositories served via hgweb.
If running an external hgweb server you should set this to an empty string.

file_path:
type: str
default: database/community_files
Expand Down
11 changes: 5 additions & 6 deletions lib/tool_shed/util/hgweb_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ class HgWebConfigManager:
def __init__(self):
self.hgweb_config_dir = None
self.in_memory_config = None
self.lock = threading.Lock()

def add_entry(self, lhs, rhs):
"""Add an entry in the hgweb.config file for a new repository."""
lock = threading.Lock()
lock.acquire(True)
self.lock.acquire(True)
try:
# Since we're changing the config, make sure the latest is loaded into memory.
self.read_config(force_read=True)
Expand All @@ -38,12 +38,11 @@ def add_entry(self, lhs, rhs):
except Exception as e:
log.debug("Exception in HgWebConfigManager.add_entry(): %s", unicodify(e))
finally:
lock.release()
self.lock.release()

def change_entry(self, old_lhs, new_lhs, new_rhs):
"""Change an entry in the hgweb.config file for a repository - this only happens when the owner changes the name of the repository."""
lock = threading.Lock()
lock.acquire(True)
self.lock.acquire(True)
try:
self.make_backup()
# Remove the old entry.
Expand All @@ -55,7 +54,7 @@ def change_entry(self, old_lhs, new_lhs, new_rhs):
except Exception as e:
log.debug("Exception in HgWebConfigManager.change_entry(): %s", unicodify(e))
finally:
lock.release()
self.lock.release()

def get_entry(self, lhs):
"""Return an entry in the hgweb.config file for a repository"""
Expand Down
2 changes: 1 addition & 1 deletion lib/tool_shed/util/repository_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def create_repository(
# Create the local repository.
init_repository(repo_path=repository_path)
# Add an entry in the hgweb.config file for the local repository.
lhs = f"repos/{repository.user.username}/{repository.name}"
lhs = f"{app.config.hgweb_repo_prefix}{repository.user.username}/{repository.name}"
app.hgweb_config_manager.add_entry(lhs, repository_path)
# Create a .hg/hgrc file for the local repository.
create_hgrc_file(app, repository)
Expand Down
Loading