forked from forgejo/forgejo
Update progress of milestones when closing/reopening issues and allow closing of issues in commit messages
This commit is contained in:
parent
6e9f1c52b1
commit
469cbc8813
4 changed files with 155 additions and 24 deletions
|
@ -7,9 +7,9 @@ package models
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"html"
|
||||
"html/template"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
|
@ -43,6 +43,7 @@ var (
|
|||
ErrRepoNameIllegal = errors.New("Repository name contains illegal characters")
|
||||
ErrRepoFileNotLoaded = errors.New("Repository file not loaded")
|
||||
ErrMirrorNotExist = errors.New("Mirror does not exist")
|
||||
ErrInvalidReference = errors.New("Invalid reference specified")
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -837,6 +838,26 @@ func DeleteRepository(userId, repoId int64, userName string) error {
|
|||
return sess.Commit()
|
||||
}
|
||||
|
||||
// GetRepositoryByRef returns a Repository specified by a GFM reference.
|
||||
// See https://help.github.com/articles/writing-on-github#references for more information on the syntax.
|
||||
func GetRepositoryByRef(ref string) (*Repository, error) {
|
||||
n := strings.IndexByte(ref, byte('/'))
|
||||
|
||||
if n < 2 {
|
||||
return nil, ErrInvalidReference
|
||||
}
|
||||
|
||||
userName, repoName := ref[:n], ref[n+1:]
|
||||
|
||||
user, err := GetUserByName(userName)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return GetRepositoryByName(user.Id, repoName)
|
||||
}
|
||||
|
||||
// GetRepositoryByName returns the repository by given name under user if exists.
|
||||
func GetRepositoryByName(userId int64, repoName string) (*Repository, error) {
|
||||
repo := &Repository{
|
||||
|
@ -1017,4 +1038,4 @@ func IsWatching(uid, rid int64) bool {
|
|||
|
||||
func ForkRepository(repoName string, uid int64) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue