GitRoot

craft your forge, build your project, grow your community freely
 1// SPDX-FileCopyrightText: 2025 Romain Maneschi <romain@gitroot.dev>
 2//
 3// SPDX-License-Identifier: EUPL-1.2
 4
 5package plugin
 6
 7import (
 8	"github.com/goccy/go-yaml"
 9	"gitroot.dev/server/user"
10)
11
12func (m *Manager) ToNewRepo(isRootRepo bool, inactiveAll bool, plugins []Plugin) ([]byte, []user.SimpleUser) {
13	toSerialize := make([]Plugin, len(plugins))
14	users := make([]user.SimpleUser, len(plugins))
15	for i, p := range plugins {
16		url := ""
17		crc := ""
18		if isRootRepo {
19			url = p.Url
20			crc = p.Crc
21		}
22		active := p.Active
23		if inactiveAll {
24			active = false
25		}
26		toSerialize[i] = Plugin{
27			Url:    url,
28			Crc:    crc,
29			Name:   p.Name,
30			Active: active,
31			Run:    p.Run,
32		}
33		users[i] = p.commiter.SimpleUser
34	}
35	b, _ := yaml.Marshal(toSerialize)
36	return b, users
37}