Skip to content

Commit

Permalink
Only wrap commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdbeek committed May 31, 2024
1 parent 6909dcb commit a910a58
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions lib/tool_shed/util/repository_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,39 +194,39 @@ def create_repository(
long_description=long_description,
user_id=user_id,
)
sa_session.add(repository)
if category_ids:
# Create category associations
for category_id in category_ids:
category = sa_session.query(app.model.Category).get(app.security.decode_id(category_id))
rca = app.model.RepositoryCategoryAssociation(repository, category)
sa_session.add(rca)
sa_session.add(repository)
# Create an admin role for the repository.
create_repository_admin_role(app, repository)
# Create a temporary repo_path on disk.
with tempfile.TemporaryDirectory(
dir=app.config.file_path, prefix="f{repository.user.username}-{repository.name}"
) as repository_path:
# Create the local repository.
init_repository(repo_path=repository_path)
# Create a .hg/hgrc file for the local repository.
create_hgrc_file(app, repository)
# Add an entry in the hgweb.config file for the local repository.
lhs = f"{app.config.hgweb_repo_prefix}{repository.user.username}/{repository.name}"
# Flush to get the id.
session = sa_session()
with transaction(session):
# Create an admin role for the repository.
create_repository_admin_role(app, repository)
# Create a temporary repo_path on disk.
with tempfile.TemporaryDirectory(
dir=app.config.file_path, prefix="f{repository.user.username}-{repository.name}"
) as repository_path:
# Create the local repository.
init_repository(repo_path=repository_path)
# Create a .hg/hgrc file for the local repository.
create_hgrc_file(app, repository)
# Add an entry in the hgweb.config file for the local repository.
lhs = f"{app.config.hgweb_repo_prefix}{repository.user.username}/{repository.name}"
# Flush to get the id.
session.commit()
dir = os.path.join(app.config.file_path, *util.directory_hash_id(repository.id))
# Define repo name inside hashed directory.
final_repository_path = os.path.join(dir, "repo_%d" % repository.id)
# Create final repository directory.
if not os.path.exists(repository_path):
os.makedirs(repository_path)
os.rename(repository_path, final_repository_path)
app.hgweb_config_manager.add_entry(lhs, final_repository_path)
# Update the repository registry.
app.repository_registry.add_entry(repository)
session.commit()
dir = os.path.join(app.config.file_path, *util.directory_hash_id(repository.id))
# Define repo name inside hashed directory.
final_repository_path = os.path.join(dir, "repo_%d" % repository.id)
# Create final repository directory.
if not os.path.exists(repository_path):
os.makedirs(repository_path)
os.rename(repository_path, final_repository_path)
app.hgweb_config_manager.add_entry(lhs, final_repository_path)
# Update the repository registry.
app.repository_registry.add_entry(repository)
message = f"Repository <b>{escape(str(repository.name))}</b> has been created."
return repository, message

Expand Down

0 comments on commit a910a58

Please sign in to comment.