Simplify parameter types (#18006)
Remove repeated type declarations in function definitions.
This commit is contained in:
parent
25677cdc5b
commit
ff2fd08228
59 changed files with 115 additions and 116 deletions
|
@ -40,7 +40,7 @@ func NewAttachment(attach *repo_model.Attachment, file io.Reader) (*repo_model.A
|
|||
}
|
||||
|
||||
// UploadAttachment upload new attachment into storage and update database
|
||||
func UploadAttachment(file io.Reader, actorID, repoID, releaseID int64, fileName string, allowedTypes string) (*repo_model.Attachment, error) {
|
||||
func UploadAttachment(file io.Reader, actorID, repoID, releaseID int64, fileName, allowedTypes string) (*repo_model.Attachment, error) {
|
||||
buf := make([]byte, 1024)
|
||||
n, _ := util.ReadAtMost(file, buf)
|
||||
buf = buf[:n]
|
||||
|
|
|
@ -111,7 +111,7 @@ func (csv *csvReader) readNextRow() ([]string, error) {
|
|||
}
|
||||
|
||||
// CreateCsvDiff creates a tabular diff based on two CSV readers.
|
||||
func CreateCsvDiff(diffFile *DiffFile, baseReader *csv.Reader, headReader *csv.Reader) ([]*TableDiffSection, error) {
|
||||
func CreateCsvDiff(diffFile *DiffFile, baseReader, headReader *csv.Reader) ([]*TableDiffSection, error) {
|
||||
if baseReader != nil && headReader != nil {
|
||||
return createCsvDiff(diffFile, baseReader, headReader)
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ func createCsvDiffSingle(reader *csv.Reader, celltype TableDiffCellType) ([]*Tab
|
|||
return []*TableDiffSection{{Rows: rows}}, nil
|
||||
}
|
||||
|
||||
func createCsvDiff(diffFile *DiffFile, baseReader *csv.Reader, headReader *csv.Reader) ([]*TableDiffSection, error) {
|
||||
func createCsvDiff(diffFile *DiffFile, baseReader, headReader *csv.Reader) ([]*TableDiffSection, error) {
|
||||
// Given the baseReader and headReader, we are going to create CSV Reader for each, baseCSVReader and b respectively
|
||||
baseCSVReader, err := createCsvReader(baseReader, maxRowsToInspect)
|
||||
if err != nil {
|
||||
|
@ -346,7 +346,7 @@ func createCsvDiff(diffFile *DiffFile, baseReader *csv.Reader, headReader *csv.R
|
|||
}
|
||||
|
||||
// getColumnMapping creates a mapping of columns between a and b
|
||||
func getColumnMapping(baseCSVReader *csvReader, headCSVReader *csvReader) ([]int, []int) {
|
||||
func getColumnMapping(baseCSVReader, headCSVReader *csvReader) ([]int, []int) {
|
||||
baseRow, _ := baseCSVReader.GetRow(0)
|
||||
headRow, _ := headCSVReader.GetRow(0)
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ func ToggleAssignee(issue *models.Issue, doer *user_model.User, assigneeID int64
|
|||
}
|
||||
|
||||
// ReviewRequest add or remove a review request from a user for this PR, and make comment for it.
|
||||
func ReviewRequest(issue *models.Issue, doer *user_model.User, reviewer *user_model.User, isAdd bool) (comment *models.Comment, err error) {
|
||||
func ReviewRequest(issue *models.Issue, doer, reviewer *user_model.User, isAdd bool) (comment *models.Comment, err error) {
|
||||
if isAdd {
|
||||
comment, err = models.AddReviewRequest(issue, reviewer, doer)
|
||||
} else {
|
||||
|
|
|
@ -606,7 +606,7 @@ func updateOptionsUnits(opts *base.MigrateOptions, units []string) {
|
|||
}
|
||||
|
||||
// RestoreRepository restore a repository from the disk directory
|
||||
func RestoreRepository(ctx context.Context, baseDir string, ownerName, repoName string, units []string) error {
|
||||
func RestoreRepository(ctx context.Context, baseDir, ownerName, repoName string, units []string) error {
|
||||
doer, err := user_model.GetAdminUser()
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -26,7 +26,7 @@ type RepositoryRestorer struct {
|
|||
}
|
||||
|
||||
// NewRepositoryRestorer creates a repository restorer which could restore repository from a dumped folder
|
||||
func NewRepositoryRestorer(ctx context.Context, baseDir string, owner, repoName string) (*RepositoryRestorer, error) {
|
||||
func NewRepositoryRestorer(ctx context.Context, baseDir, owner, repoName string) (*RepositoryRestorer, error) {
|
||||
baseDir, err := filepath.Abs(baseDir)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -22,8 +22,7 @@ import (
|
|||
)
|
||||
|
||||
// CreateCodeComment creates a comment on the code line
|
||||
func CreateCodeComment(doer *user_model.User, gitRepo *git.Repository, issue *models.Issue, line int64, content string, treePath string, isReview bool, replyReviewID int64, latestCommitID string) (*models.Comment, error) {
|
||||
|
||||
func CreateCodeComment(doer *user_model.User, gitRepo *git.Repository, issue *models.Issue, line int64, content, treePath string, isReview bool, replyReviewID int64, latestCommitID string) (*models.Comment, error) {
|
||||
var (
|
||||
existsReview bool
|
||||
err error
|
||||
|
|
|
@ -188,12 +188,12 @@ func (t *TemporaryUploadRepository) GetLastCommitByRef(ref string) (string, erro
|
|||
}
|
||||
|
||||
// CommitTree creates a commit from a given tree for the user with provided message
|
||||
func (t *TemporaryUploadRepository) CommitTree(author, committer *user_model.User, treeHash string, message string, signoff bool) (string, error) {
|
||||
func (t *TemporaryUploadRepository) CommitTree(author, committer *user_model.User, treeHash, message string, signoff bool) (string, error) {
|
||||
return t.CommitTreeWithDate(author, committer, treeHash, message, signoff, time.Now(), time.Now())
|
||||
}
|
||||
|
||||
// CommitTreeWithDate creates a commit from a given tree for the user with provided message
|
||||
func (t *TemporaryUploadRepository) CommitTreeWithDate(author, committer *user_model.User, treeHash string, message string, signoff bool, authorDate, committerDate time.Time) (string, error) {
|
||||
func (t *TemporaryUploadRepository) CommitTreeWithDate(author, committer *user_model.User, treeHash, message string, signoff bool, authorDate, committerDate time.Time) (string, error) {
|
||||
authorSig := author.NewGitSig()
|
||||
committerSig := committer.NewGitSig()
|
||||
|
||||
|
@ -263,7 +263,7 @@ func (t *TemporaryUploadRepository) CommitTreeWithDate(author, committer *user_m
|
|||
}
|
||||
|
||||
// Push the provided commitHash to the repository branch by the provided user
|
||||
func (t *TemporaryUploadRepository) Push(doer *user_model.User, commitHash string, branch string) error {
|
||||
func (t *TemporaryUploadRepository) Push(doer *user_model.User, commitHash, branch string) error {
|
||||
// Because calls hooks we need to pass in the environment
|
||||
env := models.PushingEnvironment(doer, t.repo)
|
||||
if err := git.Push(t.gitRepo.Ctx, t.basePath, git.PushOptions{
|
||||
|
|
|
@ -442,7 +442,7 @@ func CreateOrUpdateRepoFile(repo *repo_model.Repository, doer *user_model.User,
|
|||
}
|
||||
|
||||
// VerifyBranchProtection verify the branch protection for modifying the given treePath on the given branch
|
||||
func VerifyBranchProtection(repo *repo_model.Repository, doer *user_model.User, branchName string, treePath string) error {
|
||||
func VerifyBranchProtection(repo *repo_model.Repository, doer *user_model.User, branchName, treePath string) error {
|
||||
protectedBranch, err := models.GetProtectedBranchBy(repo.ID, branchName)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -18,12 +18,12 @@ import (
|
|||
type linkFormatter = func(string, string) string
|
||||
|
||||
// noneLinkFormatter does not create a link but just returns the text
|
||||
func noneLinkFormatter(url string, text string) string {
|
||||
func noneLinkFormatter(url, text string) string {
|
||||
return text
|
||||
}
|
||||
|
||||
// htmlLinkFormatter creates a HTML link
|
||||
func htmlLinkFormatter(url string, text string) string {
|
||||
func htmlLinkFormatter(url, text string) string {
|
||||
return fmt.Sprintf(`<a href="%s">%s</a>`, html.EscapeString(url), html.EscapeString(text))
|
||||
}
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ func (m *MatrixPayloadUnsafe) JSONPayload() ([]byte, error) {
|
|||
}
|
||||
|
||||
// MatrixLinkFormatter creates a link compatible with Matrix
|
||||
func MatrixLinkFormatter(url string, text string) string {
|
||||
func MatrixLinkFormatter(url, text string) string {
|
||||
return fmt.Sprintf(`<a href="%s">%s</a>`, html.EscapeString(url), html.EscapeString(text))
|
||||
}
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ func SlackShortTextFormatter(s string) string {
|
|||
}
|
||||
|
||||
// SlackLinkFormatter creates a link compatible with slack
|
||||
func SlackLinkFormatter(url string, text string) string {
|
||||
func SlackLinkFormatter(url, text string) string {
|
||||
return fmt.Sprintf("<%s|%s>", url, SlackTextFormatter(text))
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue