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

What's the best way to create a structure of nested groups? #931

Open
wojciech-kulik opened this issue Feb 11, 2024 · 0 comments
Open

What's the best way to create a structure of nested groups? #931

wojciech-kulik opened this issue Feb 11, 2024 · 0 comments

Comments

@wojciech-kulik
Copy link

wojciech-kulik commented Feb 11, 2024

Let's assume that I'm in a group A. Now I want to create a structure:

A
-- B
---- C

Is there any function that makes this task easy? Or do I have to split the path and go group by group and create it?

That's what I managed to achieve so far:

def add_group(project, group_path)
  splitted_path = group_path.split("/")

  for i in 1..(splitted_path.length - 2)
    current_path = splitted_path[0..i].join("/")
    new_group_path = current_path + "/" + splitted_path[i + 1]
    parent_group = find_group_by_absolute_dir_path(project, current_path)

    parent_group.new_group(splitted_path[i + 1], new_group_path) unless parent_group.nil?
  end

  project.save
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant