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

API for git-hook environments #10367

Open
jolheiser opened this issue Feb 19, 2020 · 0 comments
Open

API for git-hook environments #10367

jolheiser opened this issue Feb 19, 2020 · 0 comments
Labels
type/proposal The new feature has not been accepted yet but needs to be discussed first.

Comments

@jolheiser
Copy link
Member

Similar to #9093, but more focused on the available variables.
Also related to #8935, as it may benefit from having this defined.

As mentioned in #10337 (comment), this is an issue for discussing a public API for git hook environments.

What should be available in these environments?
Should certain things only be available in certain situations?
We need to be careful not to bog down the system by loading extraneous data for the sake of a hook environment. The more expensive it is, the harder it will be to justify.

I've found a few places where environments are set:

  • func FullPushingEnvironment(author, committer *User, repo *Repository, repoName string, prID int64) []string {
  • gitea/cmd/serv.go

    Lines 201 to 209 in 95013fd

    os.Setenv(models.EnvRepoIsWiki, strconv.FormatBool(results.IsWiki))
    os.Setenv(models.EnvRepoName, results.RepoName)
    os.Setenv(models.EnvRepoUsername, results.OwnerName)
    os.Setenv(models.EnvPusherName, results.UserName)
    os.Setenv(models.EnvPusherID, strconv.FormatInt(results.UserID, 10))
    os.Setenv(models.ProtectedBranchRepoID, strconv.FormatInt(results.RepoID, 10))
    os.Setenv(models.ProtectedBranchPRID, fmt.Sprintf("%d", 0))
    os.Setenv(models.EnvIsDeployKey, fmt.Sprintf("%t", results.IsDeployKey))
    os.Setenv(models.EnvKeyID, fmt.Sprintf("%d", results.KeyID))
  • gitea/routers/repo/http.go

    Lines 268 to 284 in cca13ae

    environ = []string{
    models.EnvRepoUsername + "=" + username,
    models.EnvRepoName + "=" + reponame,
    models.EnvPusherName + "=" + authUser.Name,
    models.EnvPusherID + fmt.Sprintf("=%d", authUser.ID),
    models.EnvIsDeployKey + "=false",
    }
    if !authUser.KeepEmailPrivate {
    environ = append(environ, models.EnvPusherEmail+"="+authUser.Email)
    }
    if isWiki {
    environ = append(environ, models.EnvRepoIsWiki+"=true")
    } else {
    environ = append(environ, models.EnvRepoIsWiki+"=false")
    }

    environ = append(environ, models.ProtectedBranchRepoID+fmt.Sprintf("=%d", repo.ID))

Ideally when implemented these would all converge for ease of maintanence, if possible.

@jolheiser jolheiser added the type/proposal The new feature has not been accepted yet but needs to be discussed first. label Feb 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/proposal The new feature has not been accepted yet but needs to be discussed first.
Projects
None yet
Development

No branches or pull requests

1 participant