Skip to content

[Proposal] Units of Repositories #3027

@lunny

Description

@lunny

I would like to see Gogs is modulable to resolve some questions. We can define one module I named it Unit. If you have more suitable name, please comment.

type UnitType int

const (
    UnitCode UnitType = iota
    UnitIssues
    UnitPRs
    UnitCommits
    UnitReleases
    UnitWiki
    UnitSettings
)

type Unit struct {
    UnitType
    NameKey string
    URI string
    DescKey string
    Sequence int
}

Now we have 6 units. And of course we maybe have more units in future such as Pluse, Graphs just like github's.

var (
    Units = map[UnitType]Unit{
        {
            UnitCode,
            "repo.code",
            "/",
            "repo.code_desc",
            0,
        },
        {
            UnitIssues,
            "repo.issues",
            "/issues",
            "repo.issues_desc",
            1,
        },
        {
            UnitPRs,
            "repo.pulls",
            "/pulls",
            "repo.pulls_desc",
            2,
        },
        {
            UnitCommits,
            "repo.commits",
            "/commits/master",
            "repo.commits_desc",
            3,
        },
        {
            UnitReleases,
            "repo.releases",
            "/releases",
            "repo.releases_desc",
            4,
        },
        {
            UnitWiki,
            "repo.wiki",
            "/wiki",
            "repo.wiki_desc",
            5,
        },
        {
            UnitSettings,
            "repo.settings",
            "/settings",
            "repo.settings_desc",
            6,
        }
    }
)

Then we can add one new field on Repository struct

type Repository struct {
...
Units []UnitType `xorm:"json"`
...
}

One repository could be assigned one or more units when it was created. And the old repositories could be assgined all the current units. When user visit repository page, firstly we could show units according the repository.

That is the first step.

The second we can add units on Access and Organization, Team,

type Access struct {
...
RepoID int64
UserID int64
Units []UnitType `xorm:"json"`
}

So for one person who visit repository it could only visit all allowed units.
We can define Team units, so when someone be added to this team, it will copy the team's units to this user's repository access.

type Team struct {
...
Units []UnitType `xorm:"json"`
...

I think the effect of this proposal is small. We can complete it on 2 to 3 commits.

Metadata

Metadata

Assignees

No one assigned

    Labels

    🧙 proposalLet's bring more ideas together

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions