1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-12-21 12:44:49 -05:00

WIP: create PR - choose branch

This commit is contained in:
Unknwon 2015-08-08 22:43:14 +08:00
parent d015d951bd
commit dea3a8c6a4
34 changed files with 396 additions and 212 deletions

View file

@ -146,12 +146,12 @@ func runServ(c *cli.Context) {
fail("Key permission denied", "Cannot push with deployment key: %d", key.ID)
}
// Check if this deploy key belongs to current repository.
if !models.HasDeployKey(key.ID, repo.Id) {
fail("Key access denied", "Key access denied: %d-%d", key.ID, repo.Id)
if !models.HasDeployKey(key.ID, repo.ID) {
fail("Key access denied", "Key access denied: %d-%d", key.ID, repo.ID)
}
// Update deploy key activity.
deployKey, err := models.GetDeployKeyByRepo(key.ID, repo.Id)
deployKey, err := models.GetDeployKeyByRepo(key.ID, repo.ID)
if err != nil {
fail("Internal error", "GetDeployKey: %v", err)
}

View file

@ -449,6 +449,8 @@ func runWeb(ctx *cli.Context) {
m.Get("/edit/:tagname", repo.EditRelease)
m.Post("/edit/:tagname", bindIgnErr(auth.EditReleaseForm{}), repo.EditReleasePost)
}, reqRepoAdmin, middleware.RepoRef())
m.Combo("/compare/*").Get(repo.CompareAndPullRequest)
}, reqSignIn, middleware.RepoAssignment(true))
m.Group("/:username/:reponame", func() {
@ -469,7 +471,7 @@ func runWeb(ctx *cli.Context) {
m.Get("/commit/*", repo.Diff)
}, middleware.RepoRef())
m.Get("/compare/:before([a-z0-9]+)...:after([a-z0-9]+)", repo.CompareDiff)
m.Get("/compare/:before([a-z0-9]{40})...:after([a-z0-9]{40})", repo.CompareDiff)
}, ignSignIn, middleware.RepoAssignment(true))
m.Group("/:username", func() {

View file

@ -395,6 +395,9 @@ issues.label_deletion = Label Deletion
issues.label_deletion_desc = Delete this label will remove its information in all related issues. Do you want to continue?
issues.label_deletion_success = Label has been deleted successfully!
pulls.compare_changes = Compare Changes
pulls.compare_changes_desc = Compare two branches and make a pull request for changes.
milestones.new = New Milestone
milestones.open_tab = %d Open
milestones.close_tab = %d Closed

View file

@ -37,11 +37,11 @@ func accessLevel(e Engine, u *User, repo *Repository) (AccessMode, error) {
}
if u != nil {
if u.Id == repo.OwnerId {
if u.Id == repo.OwnerID {
return ACCESS_MODE_OWNER, nil
}
a := &Access{UserID: u.Id, RepoID: repo.Id}
a := &Access{UserID: u.Id, RepoID: repo.ID}
if has, err := e.Get(a); !has || err != nil {
return mode, err
}
@ -77,7 +77,7 @@ func (u *User) GetAccessibleRepositories() (map[*Repository]AccessMode, error) {
repos := make(map[*Repository]AccessMode, len(accesses))
for _, access := range accesses {
repo, err := GetRepositoryById(access.RepoID)
repo, err := GetRepositoryByID(access.RepoID)
if err != nil {
if IsErrRepoNotExist(err) {
log.Error(4, "%v", err)
@ -87,7 +87,7 @@ func (u *User) GetAccessibleRepositories() (map[*Repository]AccessMode, error) {
}
if err = repo.GetOwner(); err != nil {
return nil, err
} else if repo.OwnerId == u.Id {
} else if repo.OwnerID == u.Id {
continue
}
repos[repo] = access.Mode
@ -121,13 +121,13 @@ func (repo *Repository) refreshAccesses(e Engine, accessMap map[int64]AccessMode
}
newAccesses = append(newAccesses, Access{
UserID: userID,
RepoID: repo.Id,
RepoID: repo.ID,
Mode: mode,
})
}
// Delete old accesses and insert new ones for repository.
if _, err = e.Delete(&Access{RepoID: repo.Id}); err != nil {
if _, err = e.Delete(&Access{RepoID: repo.ID}); err != nil {
return fmt.Errorf("delete old accesses: %v", err)
} else if _, err = e.Insert(newAccesses); err != nil {
return fmt.Errorf("insert new accesses: %v", err)
@ -193,7 +193,7 @@ func (repo *Repository) recalculateTeamAccesses(e Engine, ignTeamID int64) (err
// have relations with repository.
if t.IsOwnerTeam() {
t.Authorize = ACCESS_MODE_OWNER
} else if !t.hasRepository(e, repo.Id) {
} else if !t.hasRepository(e, repo.ID) {
continue
}

View file

@ -348,7 +348,7 @@ func CommitRepoAction(userId, repoUserId int64, userName, actEmail string,
// check if repo belongs to org and append additional webhooks
if repo.Owner.IsOrganization() {
// get hooks for org
orgws, err := GetActiveWebhooksByOrgId(repo.OwnerId)
orgws, err := GetActiveWebhooksByOrgId(repo.OwnerID)
if err != nil {
return errors.New("GetActiveWebhooksByOrgId: " + err.Error())
}
@ -388,7 +388,7 @@ func CommitRepoAction(userId, repoUserId int64, userName, actEmail string,
Ref: refFullName,
Commits: commits,
Repo: &PayloadRepo{
Id: repo.Id,
Id: repo.ID,
Name: repo.LowerName,
Url: repoLink,
Description: repo.Description,
@ -431,7 +431,7 @@ func CommitRepoAction(userId, repoUserId int64, userName, actEmail string,
}
if err = CreateHookTask(&HookTask{
RepoID: repo.Id,
RepoID: repo.ID,
HookID: w.Id,
Type: w.HookTaskType,
Url: w.Url,
@ -453,12 +453,12 @@ func newRepoAction(e Engine, u *User, repo *Repository) (err error) {
ActUserName: u.Name,
ActEmail: u.Email,
OpType: CREATE_REPO,
RepoID: repo.Id,
RepoID: repo.ID,
RepoUserName: repo.Owner.Name,
RepoName: repo.Name,
IsPrivate: repo.IsPrivate,
}); err != nil {
return fmt.Errorf("notify watchers '%d/%s'", u.Id, repo.Id)
return fmt.Errorf("notify watchers '%d/%s'", u.Id, repo.ID)
}
log.Trace("action.NewRepoAction: %s/%s", u.Name, repo.Name)
@ -476,19 +476,19 @@ func transferRepoAction(e Engine, actUser, oldOwner, newOwner *User, repo *Repos
ActUserName: actUser.Name,
ActEmail: actUser.Email,
OpType: TRANSFER_REPO,
RepoID: repo.Id,
RepoID: repo.ID,
RepoUserName: newOwner.Name,
RepoName: repo.Name,
IsPrivate: repo.IsPrivate,
Content: path.Join(oldOwner.LowerName, repo.LowerName),
}
if err = notifyWatchers(e, action); err != nil {
return fmt.Errorf("notify watchers '%d/%s'", actUser.Id, repo.Id)
return fmt.Errorf("notify watchers '%d/%s'", actUser.Id, repo.ID)
}
// Remove watch for organization.
if repo.Owner.IsOrganization() {
if err = watchRepo(e, repo.Owner.Id, repo.Id, false); err != nil {
if err = watchRepo(e, repo.Owner.Id, repo.ID, false); err != nil {
return fmt.Errorf("watch repository: %v", err)
}
}

View file

@ -68,7 +68,7 @@ func (i *Issue) AfterSet(colName string, _ xorm.Cell) {
}
func (i *Issue) GetPoster() (err error) {
i.Poster, err = GetUserById(i.PosterID)
i.Poster, err = GetUserByID(i.PosterID)
if IsErrUserNotExist(err) {
i.Poster = &User{Name: "FakeUser"}
return nil
@ -104,7 +104,7 @@ func (i *Issue) GetAssignee() (err error) {
return nil
}
i.Assignee, err = GetUserById(i.AssigneeID)
i.Assignee, err = GetUserByID(i.AssigneeID)
if IsErrUserNotExist(err) {
return nil
}
@ -170,7 +170,7 @@ func GetIssueByRef(ref string) (issue *Issue, err error) {
return
}
return GetIssueByIndex(repo.Id, issueNumber)
return GetIssueByIndex(repo.ID, issueNumber)
}
// GetIssueByIndex returns issue by given index in repository.
@ -304,7 +304,7 @@ func NewIssueUserPairs(repo *Repository, issueID, orgID, posterID, assigneeID in
iu := &IssueUser{
IssueId: issueID,
RepoId: repo.Id,
RepoId: repo.ID,
}
isNeedAddPoster := true
@ -331,9 +331,9 @@ func NewIssueUserPairs(repo *Repository, issueID, orgID, posterID, assigneeID in
}
// Add owner's as well.
if repo.OwnerId != posterID {
if repo.OwnerID != posterID {
iu.Id = 0
iu.Uid = repo.OwnerId
iu.Uid = repo.OwnerID
iu.IsAssigned = iu.Uid == assigneeID
if _, err = x.Insert(iu); err != nil {
return err
@ -760,7 +760,7 @@ func MilestoneStats(repoID int64) (open int64, closed int64) {
// ChangeMilestoneStatus changes the milestone open/closed status.
func ChangeMilestoneStatus(m *Milestone, isClosed bool) (err error) {
repo, err := GetRepositoryById(m.RepoID)
repo, err := GetRepositoryByID(m.RepoID)
if err != nil {
return err
}
@ -776,9 +776,9 @@ func ChangeMilestoneStatus(m *Milestone, isClosed bool) (err error) {
return err
}
repo.NumMilestones = int(countRepoMilestones(sess, repo.Id))
repo.NumClosedMilestones = int(countRepoClosedMilestones(sess, repo.Id))
if _, err = sess.Id(repo.Id).AllCols().Update(repo); err != nil {
repo.NumMilestones = int(countRepoMilestones(sess, repo.ID))
repo.NumClosedMilestones = int(countRepoClosedMilestones(sess, repo.ID))
if _, err = sess.Id(repo.ID).AllCols().Update(repo); err != nil {
return err
}
return sess.Commit()
@ -886,7 +886,7 @@ func DeleteMilestoneByID(mid int64) error {
return err
}
repo, err := GetRepositoryById(m.RepoID)
repo, err := GetRepositoryByID(m.RepoID)
if err != nil {
return err
}
@ -901,9 +901,9 @@ func DeleteMilestoneByID(mid int64) error {
return err
}
repo.NumMilestones = int(countRepoMilestones(sess, repo.Id))
repo.NumClosedMilestones = int(countRepoClosedMilestones(sess, repo.Id))
if _, err = sess.Id(repo.Id).AllCols().Update(repo); err != nil {
repo.NumMilestones = int(countRepoMilestones(sess, repo.ID))
repo.NumClosedMilestones = int(countRepoClosedMilestones(sess, repo.ID))
if _, err = sess.Id(repo.ID).AllCols().Update(repo); err != nil {
return err
}

View file

@ -58,7 +58,7 @@ func GetOauth2(identity string) (oa *Oauth2, err error) {
} else if oa.Uid == -1 {
return oa, ErrOauth2NotAssociated
}
oa.User, err = GetUserById(oa.Uid)
oa.User, err = GetUserByID(oa.Uid)
return oa, err
}

View file

@ -66,7 +66,7 @@ func (org *User) GetMembers() error {
org.Members = make([]*User, len(ous))
for i, ou := range ous {
org.Members[i], err = GetUserById(ou.Uid)
org.Members[i], err = GetUserByID(ou.Uid)
if err != nil {
return err
}
@ -343,11 +343,11 @@ func RemoveOrgUser(orgId, uid int64) error {
return nil
}
u, err := GetUserById(uid)
u, err := GetUserByID(uid)
if err != nil {
return fmt.Errorf("GetUserById: %v", err)
}
org, err := GetUserById(orgId)
org, err := GetUserByID(orgId)
if err != nil {
return fmt.Errorf("get organization: %v", err)
} else if err = org.GetRepositories(); err != nil {
@ -380,10 +380,10 @@ func RemoveOrgUser(orgId, uid int64) error {
// Delete all repository accesses.
access := &Access{UserID: u.Id}
for _, repo := range org.Repos {
access.RepoID = repo.Id
access.RepoID = repo.ID
if _, err = sess.Delete(access); err != nil {
return err
} else if err = watchRepo(sess, u.Id, repo.Id, false); err != nil {
} else if err = watchRepo(sess, u.Id, repo.ID, false); err != nil {
return err
}
}
@ -443,7 +443,7 @@ func (t *Team) getRepositories(e Engine) (err error) {
t.Repos = make([]*Repository, 0, len(teamRepos))
for i := range teamRepos {
repo, err := getRepositoryById(e, teamRepos[i].RepoID)
repo, err := getRepositoryByID(e, teamRepos[i].RepoID)
if err != nil {
return fmt.Errorf("getRepositoryById(%d): %v", teamRepos[i].RepoID, err)
}
@ -487,7 +487,7 @@ func (t *Team) HasRepository(repoID int64) bool {
}
func (t *Team) addRepository(e Engine, repo *Repository) (err error) {
if err = addTeamRepo(e, t.OrgID, t.ID, repo.Id); err != nil {
if err = addTeamRepo(e, t.OrgID, t.ID, repo.ID); err != nil {
return err
}
@ -504,7 +504,7 @@ func (t *Team) addRepository(e Engine, repo *Repository) (err error) {
return fmt.Errorf("getMembers: %v", err)
}
for _, u := range t.Members {
if err = watchRepo(e, u.Id, repo.Id, true); err != nil {
if err = watchRepo(e, u.Id, repo.ID, true); err != nil {
return fmt.Errorf("watchRepo: %v", err)
}
}
@ -513,9 +513,9 @@ func (t *Team) addRepository(e Engine, repo *Repository) (err error) {
// AddRepository adds new repository to team of organization.
func (t *Team) AddRepository(repo *Repository) (err error) {
if repo.OwnerId != t.OrgID {
if repo.OwnerID != t.OrgID {
return errors.New("Repository does not belong to organization")
} else if t.HasRepository(repo.Id) {
} else if t.HasRepository(repo.ID) {
return nil
}
@ -533,7 +533,7 @@ func (t *Team) AddRepository(repo *Repository) (err error) {
}
func (t *Team) removeRepository(e Engine, repo *Repository, recalculate bool) (err error) {
if err = removeTeamRepo(e, t.ID, repo.Id); err != nil {
if err = removeTeamRepo(e, t.ID, repo.ID); err != nil {
return err
}
@ -560,7 +560,7 @@ func (t *Team) removeRepository(e Engine, repo *Repository, recalculate bool) (e
continue
}
if err = watchRepo(e, u.Id, repo.Id, false); err != nil {
if err = watchRepo(e, u.Id, repo.ID, false); err != nil {
return err
}
}
@ -574,7 +574,7 @@ func (t *Team) RemoveRepository(repoID int64) error {
return nil
}
repo, err := GetRepositoryById(repoID)
repo, err := GetRepositoryByID(repoID)
if err != nil {
return err
}
@ -713,7 +713,7 @@ func DeleteTeam(t *Team) error {
}
// Get organization.
org, err := GetUserById(t.OrgID)
org, err := GetUserByID(t.OrgID)
if err != nil {
return err
}
@ -903,7 +903,7 @@ func removeTeamMember(e Engine, orgId, teamId, uid int64) error {
}
// Get organization.
org, err := getUserById(e, orgId)
org, err := getUserByID(e, orgId)
if err != nil {
return err
}

View file

@ -129,8 +129,8 @@ func NewRepoContext() {
// Repository represents a git repository.
type Repository struct {
Id int64
OwnerId int64 `xorm:"UNIQUE(s)"`
ID int64 `xorm:"pk autoincr"`
OwnerID int64 `xorm:"UNIQUE(s)"`
Owner *User `xorm:"-"`
LowerName string `xorm:"UNIQUE(s) INDEX NOT NULL"`
Name string `xorm:"INDEX NOT NULL"`
@ -159,8 +159,8 @@ type Repository struct {
*Mirror `xorm:"-"`
IsFork bool `xorm:"NOT NULL DEFAULT false"`
ForkId int64
ForkRepo *Repository `xorm:"-"`
ForkID int64
BaseRepo *Repository `xorm:"-"`
Created time.Time `xorm:"CREATED"`
Updated time.Time `xorm:"UPDATED"`
@ -168,7 +168,7 @@ type Repository struct {
func (repo *Repository) getOwner(e Engine) (err error) {
if repo.Owner == nil {
repo.Owner, err = getUserById(e, repo.OwnerId)
repo.Owner, err = getUserByID(e, repo.OwnerID)
}
return err
}
@ -178,16 +178,16 @@ func (repo *Repository) GetOwner() (err error) {
}
func (repo *Repository) GetMirror() (err error) {
repo.Mirror, err = GetMirror(repo.Id)
repo.Mirror, err = GetMirror(repo.ID)
return err
}
func (repo *Repository) GetForkRepo() (err error) {
func (repo *Repository) GetBaseRepo() (err error) {
if !repo.IsFork {
return nil
}
repo.ForkRepo, err = GetRepositoryById(repo.ForkId)
repo.BaseRepo, err = GetRepositoryByID(repo.ForkID)
return err
}
@ -211,7 +211,7 @@ func (repo *Repository) HasAccess(u *User) bool {
}
func (repo *Repository) IsOwnedBy(u *User) bool {
return repo.OwnerId == u.Id
return repo.OwnerID == u.Id
}
// DescriptionHtml does special handles to description and return HTML string.
@ -224,7 +224,7 @@ func (repo *Repository) DescriptionHtml() template.HTML {
func isRepositoryExist(e Engine, u *User, repoName string) (bool, error) {
has, err := e.Get(&Repository{
OwnerId: u.Id,
OwnerID: u.Id,
LowerName: strings.ToLower(repoName),
})
return has && com.IsDir(RepoPath(u.Name, repoName)), err
@ -287,8 +287,8 @@ func IsUsableName(name string) error {
// Mirror represents a mirror information of repository.
type Mirror struct {
Id int64
RepoId int64
ID int64 `xorm:"pk autoincr"`
RepoID int64
RepoName string // <user name>/<repo name>
Interval int // Hour.
Updated time.Time `xorm:"UPDATED"`
@ -296,7 +296,7 @@ type Mirror struct {
}
func getMirror(e Engine, repoId int64) (*Mirror, error) {
m := &Mirror{RepoId: repoId}
m := &Mirror{RepoID: repoId}
has, err := e.Get(m)
if err != nil {
return nil, err
@ -312,7 +312,7 @@ func GetMirror(repoId int64) (*Mirror, error) {
}
func updateMirror(e Engine, m *Mirror) error {
_, err := e.Id(m.Id).Update(m)
_, err := e.Id(m.ID).Update(m)
return err
}
@ -330,7 +330,7 @@ func MirrorRepository(repoId int64, userName, repoName, repoPath, url string) er
}
if _, err = x.InsertOne(&Mirror{
RepoId: repoId,
RepoID: repoId,
RepoName: strings.ToLower(userName + "/" + repoName),
Interval: 24,
NextUpdate: time.Now().Add(24 * time.Hour),
@ -365,7 +365,7 @@ func MigrateRepository(u *User, name, desc string, private, mirror bool, url str
repo.IsBare = false
if mirror {
if err = MirrorRepository(repo.Id, u.Name, repo.Name, repoPath, url); err != nil {
if err = MirrorRepository(repo.ID, u.Name, repo.Name, repoPath, url); err != nil {
return repo, err
}
repo.IsMirror = true
@ -517,7 +517,7 @@ func initRepository(e Engine, repoPath string, u *User, repo *Repository, initRe
if len(fileName) == 0 {
// Re-fetch the repository from database before updating it (else it would
// override changes that were done earlier with sql)
if repo, err = getRepositoryById(e, repo.Id); err != nil {
if repo, err = getRepositoryByID(e, repo.ID); err != nil {
return err
}
repo.IsBare = true
@ -562,7 +562,7 @@ func createRepository(e *xorm.Session, u *User, repo *Repository) (err error) {
}
}
if err = watchRepo(e, u.Id, repo.Id, true); err != nil {
if err = watchRepo(e, u.Id, repo.ID, true); err != nil {
return fmt.Errorf("watchRepo: %v", err)
} else if err = newRepoAction(e, u, repo); err != nil {
return fmt.Errorf("newRepoAction: %v", err)
@ -574,7 +574,7 @@ func createRepository(e *xorm.Session, u *User, repo *Repository) (err error) {
// CreateRepository creates a repository for given user or organization.
func CreateRepository(u *User, name, desc, lang, license string, isPrivate, isMirror, initReadme bool) (_ *Repository, err error) {
repo := &Repository{
OwnerId: u.Id,
OwnerID: u.Id,
Owner: u,
Name: name,
LowerName: strings.ToLower(name),
@ -630,12 +630,12 @@ func GetRepositoriesWithUsers(num, offset int) ([]*Repository, error) {
}
for _, repo := range repos {
repo.Owner = &User{Id: repo.OwnerId}
repo.Owner = &User{Id: repo.OwnerID}
has, err := x.Get(repo.Owner)
if err != nil {
return nil, err
} else if !has {
return nil, ErrUserNotExist{repo.OwnerId, ""}
return nil, ErrUserNotExist{repo.OwnerID, ""}
}
}
@ -672,11 +672,11 @@ func TransferOwnership(u *User, newOwnerName string, repo *Repository) error {
// Note: we have to set value here to make sure recalculate accesses is based on
// new owner.
repo.OwnerId = newOwner.Id
repo.OwnerID = newOwner.Id
repo.Owner = newOwner
// Update repository.
if _, err := sess.Id(repo.Id).Update(repo); err != nil {
if _, err := sess.Id(repo.ID).Update(repo); err != nil {
return fmt.Errorf("update owner: %v", err)
}
@ -687,7 +687,7 @@ func TransferOwnership(u *User, newOwnerName string, repo *Repository) error {
}
// Dummy object.
collaboration := &Collaboration{RepoID: repo.Id}
collaboration := &Collaboration{RepoID: repo.ID}
for _, c := range collaborators {
collaboration.UserID = c.Id
if c.Id == newOwner.Id || newOwner.IsOrgMember(c.Id) {
@ -703,7 +703,7 @@ func TransferOwnership(u *User, newOwnerName string, repo *Repository) error {
return fmt.Errorf("getTeams: %v", err)
}
for _, t := range owner.Teams {
if !t.hasRepository(sess, repo.Id) {
if !t.hasRepository(sess, repo.ID) {
continue
}
@ -713,7 +713,7 @@ func TransferOwnership(u *User, newOwnerName string, repo *Repository) error {
}
}
if err = owner.removeOrgRepo(sess, repo.Id); err != nil {
if err = owner.removeOrgRepo(sess, repo.ID); err != nil {
return fmt.Errorf("removeOrgRepo: %v", err)
}
}
@ -739,7 +739,7 @@ func TransferOwnership(u *User, newOwnerName string, repo *Repository) error {
return fmt.Errorf("decrease old owner repository count: %v", err)
}
if err = watchRepo(sess, newOwner.Id, repo.Id, true); err != nil {
if err = watchRepo(sess, newOwner.Id, repo.ID, true); err != nil {
return fmt.Errorf("watchRepo: %v", err)
} else if err = transferRepoAction(sess, u, owner, newOwner, repo); err != nil {
return fmt.Errorf("transferRepoAction: %v", err)
@ -747,7 +747,7 @@ func TransferOwnership(u *User, newOwnerName string, repo *Repository) error {
// Update mirror information.
if repo.IsMirror {
mirror, err := getMirror(sess, repo.Id)
mirror, err := getMirror(sess, repo.ID)
if err != nil {
return fmt.Errorf("getMirror: %v", err)
}
@ -794,7 +794,7 @@ func updateRepository(e Engine, repo *Repository, visibilityChanged bool) (err e
repo.Website = repo.Website[:255]
}
if _, err = e.Id(repo.Id).AllCols().Update(repo); err != nil {
if _, err = e.Id(repo.ID).AllCols().Update(repo); err != nil {
return fmt.Errorf("update: %v", err)
}
@ -831,7 +831,7 @@ func UpdateRepository(repo *Repository, visibilityChanged bool) (err error) {
// DeleteRepository deletes a repository for a user or organization.
func DeleteRepository(uid, repoID int64, userName string) error {
repo := &Repository{Id: repoID, OwnerId: uid}
repo := &Repository{ID: repoID, OwnerID: uid}
has, err := x.Get(repo)
if err != nil {
return err
@ -840,7 +840,7 @@ func DeleteRepository(uid, repoID int64, userName string) error {
}
// In case is a organization.
org, err := GetUserById(uid)
org, err := GetUserByID(uid)
if err != nil {
return err
}
@ -866,15 +866,15 @@ func DeleteRepository(uid, repoID int64, userName string) error {
}
}
if _, err = sess.Delete(&Repository{Id: repoID}); err != nil {
if _, err = sess.Delete(&Repository{ID: repoID}); err != nil {
return err
} else if _, err = sess.Delete(&Access{RepoID: repo.Id}); err != nil {
} else if _, err = sess.Delete(&Access{RepoID: repo.ID}); err != nil {
return err
} else if _, err = sess.Delete(&Action{RepoID: repo.Id}); err != nil {
} else if _, err = sess.Delete(&Action{RepoID: repo.ID}); err != nil {
return err
} else if _, err = sess.Delete(&Watch{RepoID: repoID}); err != nil {
return err
} else if _, err = sess.Delete(&Mirror{RepoId: repoID}); err != nil {
} else if _, err = sess.Delete(&Mirror{RepoID: repoID}); err != nil {
return err
} else if _, err = sess.Delete(&IssueUser{RepoId: repoID}); err != nil {
return err
@ -902,7 +902,7 @@ func DeleteRepository(uid, repoID int64, userName string) error {
}
if repo.IsFork {
if _, err = sess.Exec("UPDATE `repository` SET num_forks=num_forks-1 WHERE id=?", repo.ForkId); err != nil {
if _, err = sess.Exec("UPDATE `repository` SET num_forks=num_forks-1 WHERE id=?", repo.ForkID); err != nil {
return err
}
}
@ -946,7 +946,7 @@ func GetRepositoryByRef(ref string) (*Repository, error) {
// GetRepositoryByName returns the repository by given name under user if exists.
func GetRepositoryByName(uid int64, repoName string) (*Repository, error) {
repo := &Repository{
OwnerId: uid,
OwnerID: uid,
LowerName: strings.ToLower(repoName),
}
has, err := x.Get(repo)
@ -958,7 +958,7 @@ func GetRepositoryByName(uid int64, repoName string) (*Repository, error) {
return repo, err
}
func getRepositoryById(e Engine, id int64) (*Repository, error) {
func getRepositoryByID(e Engine, id int64) (*Repository, error) {
repo := new(Repository)
has, err := e.Id(id).Get(repo)
if err != nil {
@ -969,9 +969,9 @@ func getRepositoryById(e Engine, id int64) (*Repository, error) {
return repo, nil
}
// GetRepositoryById returns the repository by given id if exists.
func GetRepositoryById(id int64) (*Repository, error) {
return getRepositoryById(x, id)
// GetRepositoryByID returns the repository by given id if exists.
func GetRepositoryByID(id int64) (*Repository, error) {
return getRepositoryByID(x, id)
}
// GetRepositories returns a list of repositories of given user.
@ -982,8 +982,7 @@ func GetRepositories(uid int64, private bool) ([]*Repository, error) {
sess.Where("is_private=?", false)
}
err := sess.Find(&repos, &Repository{OwnerId: uid})
return repos, err
return repos, sess.Find(&repos, &Repository{OwnerID: uid})
}
// GetRecentUpdatedRepositories returns the list of repositories that are recently updated.
@ -993,8 +992,8 @@ func GetRecentUpdatedRepositories(num int) (repos []*Repository, err error) {
}
// GetRepositoryCount returns the total number of repositories of user.
func GetRepositoryCount(user *User) (int64, error) {
return x.Count(&Repository{OwnerId: user.Id})
func GetRepositoryCount(u *User) (int64, error) {
return x.Count(&Repository{OwnerID: u.Id})
}
type SearchOption struct {
@ -1199,7 +1198,7 @@ type Collaboration struct {
// Add collaborator and accompanying access
func (repo *Repository) AddCollaborator(u *User) error {
collaboration := &Collaboration{
RepoID: repo.Id,
RepoID: repo.ID,
UserID: u.Id,
}
@ -1238,13 +1237,13 @@ func (repo *Repository) AddCollaborator(u *User) error {
func (repo *Repository) getCollaborators(e Engine) ([]*User, error) {
collaborations := make([]*Collaboration, 0)
if err := e.Find(&collaborations, &Collaboration{RepoID: repo.Id}); err != nil {
if err := e.Find(&collaborations, &Collaboration{RepoID: repo.ID}); err != nil {
return nil, err
}
users := make([]*User, len(collaborations))
for i, c := range collaborations {
user, err := getUserById(e, c.UserID)
user, err := getUserByID(e, c.UserID)
if err != nil {
return nil, err
}
@ -1261,7 +1260,7 @@ func (repo *Repository) GetCollaborators() ([]*User, error) {
// Delete collaborator and accompanying access
func (repo *Repository) DeleteCollaborator(u *User) (err error) {
collaboration := &Collaboration{
RepoID: repo.Id,
RepoID: repo.ID,
UserID: u.Id,
}
@ -1430,14 +1429,14 @@ func HasForkedRepo(ownerID, repoID int64) (*Repository, bool) {
func ForkRepository(u *User, oldRepo *Repository, name, desc string) (_ *Repository, err error) {
repo := &Repository{
OwnerId: u.Id,
OwnerID: u.Id,
Owner: u,
Name: name,
LowerName: strings.ToLower(name),
Description: desc,
IsPrivate: oldRepo.IsPrivate,
IsFork: true,
ForkId: oldRepo.Id,
ForkID: oldRepo.ID,
}
sess := x.NewSession()
@ -1450,7 +1449,7 @@ func ForkRepository(u *User, oldRepo *Repository, name, desc string) (_ *Reposit
return nil, err
}
if _, err = sess.Exec("UPDATE `repository` SET num_forks=num_forks+1 WHERE id=?", oldRepo.Id); err != nil {
if _, err = sess.Exec("UPDATE `repository` SET num_forks=num_forks+1 WHERE id=?", oldRepo.ID); err != nil {
return nil, err
}

View file

@ -105,7 +105,7 @@ func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName
commit := &base.PushCommits{}
if err = CommitRepoAction(userId, ru.Id, userName, actEmail,
repos.Id, repoUserName, repoName, refName, commit, oldCommitId, newCommitId); err != nil {
repos.ID, repoUserName, repoName, refName, commit, oldCommitId, newCommitId); err != nil {
log.GitLogger.Fatal(4, "CommitRepoAction: %s/%s:%v", repoUserName, repoName, err)
}
return err
@ -154,7 +154,7 @@ func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName
}
if err = CommitRepoAction(userId, ru.Id, userName, actEmail,
repos.Id, repoUserName, repoName, refName, &base.PushCommits{l.Len(), commits, ""}, oldCommitId, newCommitId); err != nil {
repos.ID, repoUserName, repoName, refName, &base.PushCommits{l.Len(), commits, ""}, oldCommitId, newCommitId); err != nil {
return fmt.Errorf("runUpdate.models.CommitRepoAction: %s/%s:%v", repoUserName, repoName, err)
}
return nil

View file

@ -226,7 +226,7 @@ func (u *User) GetOrganizations() error {
u.Orgs = make([]*User, len(ous))
for i, ou := range ous {
u.Orgs[i], err = GetUserById(ou.OrgID)
u.Orgs[i], err = GetUserByID(ou.OrgID)
if err != nil {
return err
}
@ -555,7 +555,7 @@ func GetUserByKeyId(keyId int64) (*User, error) {
return user, nil
}
func getUserById(e Engine, id int64) (*User, error) {
func getUserByID(e Engine, id int64) (*User, error) {
u := new(User)
has, err := e.Id(id).Get(u)
if err != nil {
@ -566,9 +566,9 @@ func getUserById(e Engine, id int64) (*User, error) {
return u, nil
}
// GetUserById returns the user object by given ID if exists.
func GetUserById(id int64) (*User, error) {
return getUserById(x, id)
// GetUserByID returns the user object by given ID if exists.
func GetUserByID(id int64) (*User, error) {
return getUserByID(x, id)
}
// GetUserByName returns user by given name.
@ -620,7 +620,7 @@ func GetEmailAddresses(uid int64) ([]*EmailAddress, error) {
return nil, err
}
u, err := GetUserById(uid)
u, err := GetUserByID(uid)
if err != nil {
return nil, err
}
@ -666,7 +666,7 @@ func (email *EmailAddress) Activate() error {
return err
}
if user, err := GetUserById(email.Uid); err != nil {
if user, err := GetUserByID(email.Uid); err != nil {
return err
} else {
user.Rands = GetUserSalt()
@ -793,7 +793,7 @@ func GetUserByEmail(email string) (*User, error) {
return nil, err
}
if has {
return GetUserById(emailAddress.Uid)
return GetUserByID(emailAddress.Uid)
}
return nil, ErrUserNotExist{0, "email"}

View file

@ -54,7 +54,7 @@ func SignedInId(req *http.Request, sess session.Store) int64 {
return 0
}
if id, ok := uid.(int64); ok {
if _, err := models.GetUserById(id); err != nil {
if _, err := models.GetUserByID(id); err != nil {
if !models.IsErrUserNotExist(err) {
log.Error(4, "GetUserById: %v", err)
}
@ -127,7 +127,7 @@ func SignedInUser(req *http.Request, sess session.Store) (*models.User, bool) {
return nil, false
}
u, err := models.GetUserById(uid)
u, err := models.GetUserByID(uid)
if err != nil {
log.Error(4, "GetUserById: %v", err)
return nil, false

File diff suppressed because one or more lines are too long

View file

@ -156,7 +156,7 @@ func SendResetPasswdMail(r macaron.Render, u *models.User) {
// SendIssueNotifyMail sends mail notification of all watchers of repository.
func SendIssueNotifyMail(u, owner *models.User, repo *models.Repository, issue *models.Issue) ([]string, error) {
ws, err := models.GetWatchers(repo.Id)
ws, err := models.GetWatchers(repo.ID)
if err != nil {
return nil, errors.New("mail.NotifyWatchers(GetWatchers): " + err.Error())
}
@ -167,7 +167,7 @@ func SendIssueNotifyMail(u, owner *models.User, repo *models.Repository, issue *
if u.Id == uid {
continue
}
u, err := models.GetUserById(uid)
u, err := models.GetUserByID(uid)
if err != nil {
return nil, errors.New("mail.NotifyWatchers(GetUserById): " + err.Error())
}

View file

@ -257,7 +257,7 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler {
ctx.Data["HasAccess"] = true
if repo.IsMirror {
ctx.Repo.Mirror, err = models.GetMirror(repo.Id)
ctx.Repo.Mirror, err = models.GetMirror(repo.ID)
if err != nil {
ctx.Handle(500, "GetMirror", err)
return
@ -291,10 +291,34 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler {
ctx.Data["Tags"] = tags
ctx.Repo.Repository.NumTags = len(tags)
// Non-fork repository will not return error in this method.
if err = repo.GetForkRepo(); err != nil {
ctx.Handle(500, "GetForkRepo", err)
return
if repo.IsFork {
// Non-fork repository will not return error in this method.
if err = repo.GetBaseRepo(); err != nil {
ctx.Handle(500, "GetBaseRepo", err)
return
} else if repo.BaseRepo.GetOwner(); err != nil {
ctx.Handle(500, "BaseRepo.GetOwner", err)
return
}
bsaeRepo := repo.BaseRepo
baseGitRepo, err := git.OpenRepository(models.RepoPath(bsaeRepo.Owner.Name, bsaeRepo.Name))
if err != nil {
ctx.Handle(500, "OpenRepository", err)
return
}
if len(bsaeRepo.DefaultBranch) > 0 && baseGitRepo.IsBranchExist(bsaeRepo.DefaultBranch) {
ctx.Data["BaseDefaultBranch"] = bsaeRepo.DefaultBranch
} else {
baseBranches, err := baseGitRepo.GetBranches()
if err != nil {
ctx.Handle(500, "GetBranches", err)
return
}
if len(baseBranches) > 0 {
ctx.Data["BaseDefaultBranch"] = baseBranches[0]
}
}
}
ctx.Data["Title"] = u.Name + "/" + repo.Name
@ -327,8 +351,8 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler {
}
if ctx.IsSigned {
ctx.Data["IsWatchingRepo"] = models.IsWatching(ctx.User.Id, repo.Id)
ctx.Data["IsStaringRepo"] = models.IsStaring(ctx.User.Id, repo.Id)
ctx.Data["IsWatchingRepo"] = models.IsWatching(ctx.User.Id, repo.ID)
ctx.Data["IsStaringRepo"] = models.IsStaring(ctx.User.Id, repo.ID)
}
ctx.Data["TagName"] = ctx.Repo.TagName
@ -342,8 +366,8 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler {
// If not branch selected, try default one.
// If default branch doesn't exists, fall back to some other branch.
if ctx.Repo.BranchName == "" {
if ctx.Repo.Repository.DefaultBranch != "" && gitRepo.IsBranchExist(ctx.Repo.Repository.DefaultBranch) {
if len(ctx.Repo.BranchName) == 0 {
if len(ctx.Repo.Repository.DefaultBranch) > 0 && gitRepo.IsBranchExist(ctx.Repo.Repository.DefaultBranch) {
ctx.Repo.BranchName = ctx.Repo.Repository.DefaultBranch
} else if len(brs) > 0 {
ctx.Repo.BranchName = brs[0]

File diff suppressed because one or more lines are too long

View file

@ -93,6 +93,17 @@ function initRepository() {
$('#add-deploy-key-panel').show();
});
}
// Pull request
if ($('.repository.compare.pull').length > 0) {
$('.choose.branch .dropdown').dropdown({
action: 'hide',
fullTextSearch: true,
onNoResults: function () {
$('.choose.branch .dropdown .active').addClass('selected');
}
});
}
};
$(document).ready(function () {

View file

@ -223,6 +223,46 @@
padding-left: 20px!important;
}
}
&.compare.pull {
.choose.branch {
.octicon {
padding-right: 10px;
}
}
}
.filter.dropdown .menu {
margin-top: 1px!important;
.items {
max-height: 300px;
overflow-y: auto;
.item {
position: relative;
cursor: pointer;
display: block;
border: none;
height: auto;
border-top: none;
line-height: 1em;
color: rgba(0,0,0,.8);
padding: .71428571em 1.14285714em!important;
font-size: 1rem;
text-transform: none;
font-weight: 400;
box-shadow: none;
-webkit-touch-callout: none;
&.active {
font-weight: 700;
}
&:hover {
background: rgba(0,0,0,.05);
color: rgba(0,0,0,.8);
z-index: 13;
}
}
}
}
}
.settings .key.list {

View file

@ -139,9 +139,9 @@ func EditUser(ctx *middleware.Context) {
return
}
u, err := models.GetUserById(uid)
u, err := models.GetUserByID(uid)
if err != nil {
ctx.Handle(500, "GetUserById", err)
ctx.Handle(500, "GetUserByID", err)
return
}
@ -166,7 +166,7 @@ func EditUserPost(ctx *middleware.Context, form auth.AdminEditUserForm) {
return
}
u, err := models.GetUserById(uid)
u, err := models.GetUserByID(uid)
if err != nil {
ctx.Handle(500, "GetUserById", err)
return
@ -219,9 +219,9 @@ func DeleteUser(ctx *middleware.Context) {
return
}
u, err := models.GetUserById(uid)
u, err := models.GetUserByID(uid)
if err != nil {
ctx.Handle(500, "GetUserById", err)
ctx.Handle(500, "GetUserByID", err)
return
}

View file

@ -28,7 +28,7 @@ func ToApiRepository(owner *models.User, repo *models.Repository, permission api
log.Error(4, "CloneLink: %v", err)
}
return &api.Repository{
Id: repo.Id,
Id: repo.ID,
Owner: *ToApiUser(owner),
FullName: owner.Name + "/" + repo.Name,
Private: repo.IsPrivate,
@ -55,7 +55,7 @@ func SearchRepos(ctx *middleware.Context) {
if ctx.User.Id == opt.Uid {
opt.Private = true
} else {
u, err := models.GetUserById(opt.Uid)
u, err := models.GetUserByID(opt.Uid)
if err != nil {
ctx.JSON(500, map[string]interface{}{
"ok": false,
@ -89,7 +89,7 @@ func SearchRepos(ctx *middleware.Context) {
return
}
results[i] = &api.Repository{
Id: repos[i].Id,
Id: repos[i].ID,
FullName: path.Join(repos[i].Owner.Name, repos[i].Name),
}
}
@ -111,7 +111,7 @@ func createRepo(ctx *middleware.Context, owner *models.User, opt api.CreateRepoO
} else {
log.Error(4, "CreateRepository: %v", err)
if repo != nil {
if err = models.DeleteRepository(ctx.User.Id, repo.Id, ctx.User.Name); err != nil {
if err = models.DeleteRepository(ctx.User.Id, repo.ID, ctx.User.Name); err != nil {
log.Error(4, "DeleteRepository: %v", err)
}
}
@ -172,7 +172,7 @@ func MigrateRepo(ctx *middleware.Context, form auth.MigrateRepoForm) {
ctxUser := u
// Not equal means current user is an organization.
if form.Uid != u.Id {
org, err := models.GetUserById(form.Uid)
org, err := models.GetUserByID(form.Uid)
if err != nil {
if models.IsErrUserNotExist(err) {
ctx.HandleAPI(422, err)
@ -219,7 +219,7 @@ func MigrateRepo(ctx *middleware.Context, form auth.MigrateRepoForm) {
repo, err := models.MigrateRepository(ctxUser, form.RepoName, form.Description, form.Private, form.Mirror, remoteAddr)
if err != nil {
if repo != nil {
if errDelete := models.DeleteRepository(ctxUser.Id, repo.Id, ctxUser.Name); errDelete != nil {
if errDelete := models.DeleteRepository(ctxUser.Id, repo.ID, ctxUser.Name); errDelete != nil {
log.Error(4, "DeleteRepository: %v", errDelete)
}
}

View file

@ -17,7 +17,7 @@ import (
// GET /repos/:username/:reponame/hooks
// https://developer.github.com/v3/repos/hooks/#list-hooks
func ListRepoHooks(ctx *middleware.Context) {
hooks, err := models.GetWebhooksByRepoId(ctx.Repo.Repository.Id)
hooks, err := models.GetWebhooksByRepoId(ctx.Repo.Repository.ID)
if err != nil {
ctx.JSON(500, &base.ApiJsonErr{"GetWebhooksByRepoId: " + err.Error(), base.DOC_URL})
return
@ -67,7 +67,7 @@ func CreateRepoHook(ctx *middleware.Context, form api.CreateHookOption) {
}
w := &models.Webhook{
RepoId: ctx.Repo.Repository.Id,
RepoId: ctx.Repo.Repository.ID,
Url: form.Config["url"],
ContentType: models.ToHookContentType(form.Config["content_type"]),
Secret: form.Config["secret"],

View file

@ -57,7 +57,7 @@ func Explore(ctx *middleware.Context) {
}
for _, repo := range repos {
if err = repo.GetOwner(); err != nil {
ctx.Handle(500, "GetOwner", fmt.Errorf("%d: %v", repo.Id, err))
ctx.Handle(500, "GetOwner", fmt.Errorf("%d: %v", repo.ID, err))
return
}
}

View file

@ -122,7 +122,7 @@ func Http(ctx *middleware.Context) {
}
return
}
authUser, err = models.GetUserById(token.Uid)
authUser, err = models.GetUserByID(token.Uid)
if err != nil {
ctx.Handle(500, "GetUserById", err)
return
@ -191,7 +191,7 @@ func Http(ctx *middleware.Context) {
// FIXME: handle error.
if err = models.Update(refName, oldCommitId, newCommitId, authUsername, username, reponame, authUser.Id); err == nil {
models.HookQueue.AddRepoID(repo.Id)
models.HookQueue.AddRepoID(repo.ID)
}
}

View file

@ -44,7 +44,7 @@ var (
)
func RetrieveLabels(ctx *middleware.Context) {
labels, err := models.GetLabels(ctx.Repo.Repository.Id)
labels, err := models.GetLabels(ctx.Repo.Repository.ID)
if err != nil {
ctx.Handle(500, "RetrieveLabels.GetLabels: %v", err)
return
@ -95,7 +95,7 @@ func Issues(ctx *middleware.Context) {
selectLabels := ctx.Query("labels")
milestoneID := ctx.QueryInt64("milestone")
isShowClosed := ctx.Query("state") == "closed"
issueStats := models.GetIssueStats(repo.Id, uid, com.StrTo(selectLabels).MustInt64(), milestoneID, isShowClosed, filterMode)
issueStats := models.GetIssueStats(repo.ID, uid, com.StrTo(selectLabels).MustInt64(), milestoneID, isShowClosed, filterMode)
page := ctx.QueryInt("page")
if page <= 1 {
@ -111,7 +111,7 @@ func Issues(ctx *middleware.Context) {
ctx.Data["Page"] = paginater.New(total, setting.IssuePagingNum, page, 5)
// Get issues.
issues, err := models.Issues(uid, assigneeID, repo.Id, posterID, milestoneID,
issues, err := models.Issues(uid, assigneeID, repo.ID, posterID, milestoneID,
page, isShowClosed, filterMode == models.FM_MENTION, selectLabels, ctx.Query("sortType"))
if err != nil {
ctx.Handle(500, "GetIssues: %v", err)
@ -119,7 +119,7 @@ func Issues(ctx *middleware.Context) {
}
// Get issue-user pairs.
pairs, err := models.GetIssueUserPairs(repo.Id, posterID, isShowClosed)
pairs, err := models.GetIssueUserPairs(repo.ID, posterID, isShowClosed)
if err != nil {
ctx.Handle(500, "GetIssueUserPairs: %v", err)
return
@ -153,7 +153,7 @@ func Issues(ctx *middleware.Context) {
ctx.Data["Issues"] = issues
// Get milestones.
miles, err := models.GetAllRepoMilestones(repo.Id)
miles, err := models.GetAllRepoMilestones(repo.ID)
if err != nil {
ctx.Handle(500, "GetAllRepoMilestones: %v", err)
return
@ -185,12 +185,12 @@ func CreateIssue(ctx *middleware.Context) {
err error
)
// Get all milestones.
ctx.Data["OpenMilestones"], err = models.GetMilestones(repo.Id, -1, false)
ctx.Data["OpenMilestones"], err = models.GetMilestones(repo.ID, -1, false)
if err != nil {
ctx.Handle(500, "GetMilestones.1: %v", err)
return
}
ctx.Data["ClosedMilestones"], err = models.GetMilestones(repo.Id, -1, true)
ctx.Data["ClosedMilestones"], err = models.GetMilestones(repo.ID, -1, true)
if err != nil {
ctx.Handle(500, "GetMilestones.2: %v", err)
return
@ -229,12 +229,12 @@ func CreateIssuePost(ctx *middleware.Context, form auth.CreateIssueForm) {
var err error
// Get all milestones.
_, err = models.GetMilestones(ctx.Repo.Repository.Id, -1, false)
_, err = models.GetMilestones(ctx.Repo.Repository.ID, -1, false)
if err != nil {
send(500, nil, err)
return
}
_, err = models.GetMilestones(ctx.Repo.Repository.Id, -1, true)
_, err = models.GetMilestones(ctx.Repo.Repository.ID, -1, true)
if err != nil {
send(500, nil, err)
return
@ -256,7 +256,7 @@ func CreateIssuePost(ctx *middleware.Context, form auth.CreateIssueForm) {
form.AssigneeId = 0
}
issue := &models.Issue{
RepoID: ctx.Repo.Repository.Id,
RepoID: ctx.Repo.Repository.ID,
Index: int64(ctx.Repo.Repository.NumIssues) + 1,
Name: form.IssueName,
PosterID: ctx.User.Id,
@ -297,7 +297,7 @@ func CreateIssuePost(ctx *middleware.Context, form auth.CreateIssueForm) {
ActEmail: ctx.User.Email,
OpType: models.CREATE_ISSUE,
Content: fmt.Sprintf("%d|%s", issue.Index, issue.Name),
RepoID: ctx.Repo.Repository.Id,
RepoID: ctx.Repo.Repository.ID,
RepoUserName: ctx.Repo.Owner.Name,
RepoName: ctx.Repo.Repository.Name,
RefName: ctx.Repo.BranchName,
@ -332,7 +332,7 @@ func CreateIssuePost(ctx *middleware.Context, form auth.CreateIssueForm) {
return
}
}
log.Trace("%d Issue created: %d", ctx.Repo.Repository.Id, issue.ID)
log.Trace("%d Issue created: %d", ctx.Repo.Repository.ID, issue.ID)
send(200, fmt.Sprintf("%s/%s/%s/issues/%d", setting.AppSubUrl, ctx.Params(":username"), ctx.Params(":reponame"), issue.Index), nil)
}
@ -357,7 +357,7 @@ func ViewIssue(ctx *middleware.Context) {
return
}
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.Id, idx)
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, idx)
if err != nil {
if err == models.ErrIssueNotExist {
ctx.Handle(404, "GetIssueByIndex", err)
@ -372,7 +372,7 @@ func ViewIssue(ctx *middleware.Context) {
ctx.Handle(500, "GetLabels", err)
return
}
labels, err := models.GetLabels(ctx.Repo.Repository.Id)
labels, err := models.GetLabels(ctx.Repo.Repository.ID)
if err != nil {
ctx.Handle(500, "GetLabels.2", err)
return
@ -394,12 +394,12 @@ func ViewIssue(ctx *middleware.Context) {
}
// Get all milestones.
ctx.Data["OpenMilestones"], err = models.GetMilestones(ctx.Repo.Repository.Id, -1, false)
ctx.Data["OpenMilestones"], err = models.GetMilestones(ctx.Repo.Repository.ID, -1, false)
if err != nil {
ctx.Handle(500, "GetMilestones.1: %v", err)
return
}
ctx.Data["ClosedMilestones"], err = models.GetMilestones(ctx.Repo.Repository.Id, -1, true)
ctx.Data["ClosedMilestones"], err = models.GetMilestones(ctx.Repo.Repository.ID, -1, true)
if err != nil {
ctx.Handle(500, "GetMilestones.2: %v", err)
return
@ -439,7 +439,7 @@ func ViewIssue(ctx *middleware.Context) {
// Get posters.
for i := range comments {
u, err := models.GetUserById(comments[i].PosterId)
u, err := models.GetUserByID(comments[i].PosterId)
if err != nil {
ctx.Handle(500, "GetUserById.2: %v", err)
return
@ -469,7 +469,7 @@ func UpdateIssue(ctx *middleware.Context, form auth.CreateIssueForm) {
return
}
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.Id, idx)
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, idx)
if err != nil {
if err == models.ErrIssueNotExist {
ctx.Handle(404, "issue.UpdateIssue", err)
@ -517,7 +517,7 @@ func UpdateIssueLabel(ctx *middleware.Context) {
return
}
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.Id, idx)
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, idx)
if err != nil {
if err == models.ErrIssueNotExist {
ctx.Handle(404, "issue.UpdateIssueLabel(GetIssueByIndex)", err)
@ -762,7 +762,7 @@ func Comment(ctx *middleware.Context) {
return
}
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.Id, index)
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, index)
if err != nil {
if err == models.ErrIssueNotExist {
send(404, nil, err)
@ -820,7 +820,7 @@ func Comment(ctx *middleware.Context) {
cmtType = models.COMMENT_TYPE_REOPEN
}
if _, err = models.CreateComment(ctx.User.Id, ctx.Repo.Repository.Id, issue.ID, 0, 0, cmtType, "", nil); err != nil {
if _, err = models.CreateComment(ctx.User.Id, ctx.Repo.Repository.ID, issue.ID, 0, 0, cmtType, "", nil); err != nil {
send(200, nil, err)
return
}
@ -836,7 +836,7 @@ func Comment(ctx *middleware.Context) {
if len(content) > 0 || len(ctx.Req.MultipartForm.File["attachments"]) > 0 {
switch ctx.Params(":action") {
case "new":
if comment, err = models.CreateComment(ctx.User.Id, ctx.Repo.Repository.Id, issue.ID, 0, 0, models.COMMENT_TYPE_COMMENT, content, nil); err != nil {
if comment, err = models.CreateComment(ctx.User.Id, ctx.Repo.Repository.ID, issue.ID, 0, 0, models.COMMENT_TYPE_COMMENT, content, nil); err != nil {
send(500, nil, err)
return
}
@ -872,7 +872,7 @@ func Comment(ctx *middleware.Context) {
ActEmail: ctx.User.Email,
OpType: models.COMMENT_ISSUE,
Content: fmt.Sprintf("%d|%s", issue.Index, strings.Split(content, "\n")[0]),
RepoID: ctx.Repo.Repository.Id,
RepoID: ctx.Repo.Repository.ID,
RepoUserName: ctx.Repo.Owner.LowerName,
RepoName: ctx.Repo.Repository.LowerName,
IsPrivate: ctx.Repo.Repository.IsPrivate,
@ -927,7 +927,7 @@ func NewLabel(ctx *middleware.Context, form auth.CreateLabelForm) {
}
l := &models.Label{
RepoId: ctx.Repo.Repository.Id,
RepoId: ctx.Repo.Repository.ID,
Name: form.Title,
Color: form.Color,
}
@ -960,7 +960,7 @@ func UpdateLabel(ctx *middleware.Context, form auth.CreateLabelForm) {
}
func DeleteLabel(ctx *middleware.Context) {
if err := models.DeleteLabel(ctx.Repo.Repository.Id, ctx.QueryInt64("id")); err != nil {
if err := models.DeleteLabel(ctx.Repo.Repository.ID, ctx.QueryInt64("id")); err != nil {
ctx.Flash.Error("DeleteLabel: " + err.Error())
} else {
ctx.Flash.Success(ctx.Tr("repo.issues.label_deletion_success"))
@ -977,7 +977,7 @@ func Milestones(ctx *middleware.Context) {
ctx.Data["PageIsMilestones"] = true
isShowClosed := ctx.Query("state") == "closed"
openCount, closedCount := models.MilestoneStats(ctx.Repo.Repository.Id)
openCount, closedCount := models.MilestoneStats(ctx.Repo.Repository.ID)
ctx.Data["OpenCount"] = openCount
ctx.Data["ClosedCount"] = closedCount
@ -994,7 +994,7 @@ func Milestones(ctx *middleware.Context) {
}
ctx.Data["Page"] = paginater.New(total, setting.IssuePagingNum, page, 5)
miles, err := models.GetMilestones(ctx.Repo.Repository.Id, page, isShowClosed)
miles, err := models.GetMilestones(ctx.Repo.Repository.ID, page, isShowClosed)
if err != nil {
ctx.Handle(500, "GetMilestones", err)
return
@ -1043,7 +1043,7 @@ func NewMilestonePost(ctx *middleware.Context, form auth.CreateMilestoneForm) {
}
if err = models.NewMilestone(&models.Milestone{
RepoID: ctx.Repo.Repository.Id,
RepoID: ctx.Repo.Repository.ID,
Name: form.Title,
Content: form.Content,
Deadline: deadline,

View file

@ -5,26 +5,31 @@
package repo
import (
"fmt"
"strings"
"github.com/gogits/gogs/models"
"github.com/gogits/gogs/modules/auth"
"github.com/gogits/gogs/modules/base"
"github.com/gogits/gogs/modules/git"
"github.com/gogits/gogs/modules/log"
"github.com/gogits/gogs/modules/middleware"
"github.com/gogits/gogs/modules/setting"
)
const (
FORK base.TplName = "repo/pulls/fork"
PULLS base.TplName = "repo/pulls"
FORK base.TplName = "repo/pulls/fork"
COMPARE_PULL base.TplName = "repo/pulls/compare"
PULLS base.TplName = "repo/pulls"
)
func getForkRepository(ctx *middleware.Context) *models.Repository {
forkRepo, err := models.GetRepositoryById(ctx.ParamsInt64(":repoid"))
forkRepo, err := models.GetRepositoryByID(ctx.ParamsInt64(":repoid"))
if err != nil {
if models.IsErrRepoNotExist(err) {
ctx.Handle(404, "GetRepositoryById", nil)
ctx.Handle(404, "GetRepositoryByID", nil)
} else {
ctx.Handle(500, "GetRepositoryById", err)
ctx.Handle(500, "GetRepositoryByID", err)
}
return nil
}
@ -78,7 +83,7 @@ func ForkPost(ctx *middleware.Context, form auth.CreateRepoForm) {
return
}
repo, has := models.HasForkedRepo(ctxUser.Id, forkRepo.Id)
repo, has := models.HasForkedRepo(ctxUser.Id, forkRepo.ID)
if has {
ctx.Redirect(setting.AppSubUrl + "/" + ctxUser.Name + "/" + repo.Name)
return
@ -110,10 +115,56 @@ func ForkPost(ctx *middleware.Context, form auth.CreateRepoForm) {
return
}
log.Trace("Repository forked[%d]: %s/%s", forkRepo.Id, ctxUser.Name, repo.Name)
log.Trace("Repository forked[%d]: %s/%s", forkRepo.ID, ctxUser.Name, repo.Name)
ctx.Redirect(setting.AppSubUrl + "/" + ctxUser.Name + "/" + repo.Name)
}
func CompareAndPullRequest(ctx *middleware.Context) {
// Get compare information.
infos := strings.Split(ctx.Params("*"), "...")
if len(infos) != 2 {
ctx.Handle(404, "CompareAndPullRequest", nil)
return
}
baseBranch := infos[0]
ctx.Data["BaseBranch"] = baseBranch
headInfos := strings.Split(infos[1], ":")
if len(headInfos) != 2 {
ctx.Handle(404, "CompareAndPullRequest", nil)
return
}
headUser := headInfos[0]
headBranch := headInfos[1]
ctx.Data["HeadBranch"] = headBranch
// TODO: check if branches are valid.
fmt.Println(baseBranch, headUser, headBranch)
// TODO: add organization support
// Check if current user has fork of repository.
headRepo, has := models.HasForkedRepo(ctx.User.Id, ctx.Repo.Repository.ID)
if !has {
ctx.Handle(404, "HasForkedRepo", nil)
return
}
headGitRepo, err := git.OpenRepository(models.RepoPath(ctx.User.Name, headRepo.Name))
if err != nil {
ctx.Handle(500, "OpenRepository", err)
return
}
headBranches, err := headGitRepo.GetBranches()
if err != nil {
ctx.Handle(500, "GetBranches", err)
return
}
ctx.Data["HeadBranches"] = headBranches
ctx.HTML(200, COMPARE_PULL)
}
func Pulls(ctx *middleware.Context) {
ctx.Data["IsRepoToolbarPulls"] = true
ctx.HTML(200, PULLS)

View file

@ -29,7 +29,7 @@ func Releases(ctx *middleware.Context) {
return
}
rels, err := models.GetReleasesByRepoId(ctx.Repo.Repository.Id)
rels, err := models.GetReleasesByRepoId(ctx.Repo.Repository.ID)
if err != nil {
ctx.Handle(500, "GetReleasesByRepoId", err)
return
@ -45,7 +45,7 @@ func Releases(ctx *middleware.Context) {
continue
}
if rel.TagName == rawTag {
rel.Publisher, err = models.GetUserById(rel.PublisherId)
rel.Publisher, err = models.GetUserByID(rel.PublisherId)
if err != nil {
ctx.Handle(500, "GetUserById", err)
return
@ -105,7 +105,7 @@ func Releases(ctx *middleware.Context) {
continue
}
rel.Publisher, err = models.GetUserById(rel.PublisherId)
rel.Publisher, err = models.GetUserByID(rel.PublisherId)
if err != nil {
ctx.Handle(500, "GetUserById", err)
return
@ -185,7 +185,7 @@ func NewReleasePost(ctx *middleware.Context, form auth.NewReleaseForm) {
}
rel := &models.Release{
RepoId: ctx.Repo.Repository.Id,
RepoId: ctx.Repo.Repository.ID,
PublisherId: ctx.User.Id,
Title: form.Title,
TagName: form.TagName,
@ -217,7 +217,7 @@ func EditRelease(ctx *middleware.Context) {
}
tagName := ctx.Params(":tagname")
rel, err := models.GetRelease(ctx.Repo.Repository.Id, tagName)
rel, err := models.GetRelease(ctx.Repo.Repository.ID, tagName)
if err != nil {
if err == models.ErrReleaseNotExist {
ctx.Handle(404, "GetRelease", err)
@ -240,7 +240,7 @@ func EditReleasePost(ctx *middleware.Context, form auth.EditReleaseForm) {
}
tagName := ctx.Params(":tagname")
rel, err := models.GetRelease(ctx.Repo.Repository.Id, tagName)
rel, err := models.GetRelease(ctx.Repo.Repository.ID, tagName)
if err != nil {
if err == models.ErrReleaseNotExist {
ctx.Handle(404, "GetRelease", err)

View file

@ -33,7 +33,7 @@ func checkContextUser(ctx *middleware.Context, uid int64) *models.User {
return ctx.User
}
org, err := models.GetUserById(uid)
org, err := models.GetUserByID(uid)
if models.IsErrUserNotExist(err) {
return ctx.User
}
@ -112,7 +112,7 @@ func CreatePost(ctx *middleware.Context, form auth.CreateRepoForm) {
}
if repo != nil {
if errDelete := models.DeleteRepository(ctxUser.Id, repo.Id, ctxUser.Name); errDelete != nil {
if errDelete := models.DeleteRepository(ctxUser.Id, repo.ID, ctxUser.Name); errDelete != nil {
log.Error(4, "DeleteRepository: %v", errDelete)
}
}
@ -209,7 +209,7 @@ func MigratePost(ctx *middleware.Context, form auth.MigrateRepoForm) {
}
if repo != nil {
if errDelete := models.DeleteRepository(ctxUser.Id, repo.Id, ctxUser.Name); errDelete != nil {
if errDelete := models.DeleteRepository(ctxUser.Id, repo.ID, ctxUser.Name); errDelete != nil {
log.Error(4, "DeleteRepository: %v", errDelete)
}
}
@ -239,13 +239,13 @@ func Action(ctx *middleware.Context) {
var err error
switch ctx.Params(":action") {
case "watch":
err = models.WatchRepo(ctx.User.Id, ctx.Repo.Repository.Id, true)
err = models.WatchRepo(ctx.User.Id, ctx.Repo.Repository.ID, true)
case "unwatch":
err = models.WatchRepo(ctx.User.Id, ctx.Repo.Repository.Id, false)
err = models.WatchRepo(ctx.User.Id, ctx.Repo.Repository.ID, false)
case "star":
err = models.StarRepo(ctx.User.Id, ctx.Repo.Repository.Id, true)
err = models.StarRepo(ctx.User.Id, ctx.Repo.Repository.ID, true)
case "unstar":
err = models.StarRepo(ctx.User.Id, ctx.Repo.Repository.Id, false)
err = models.StarRepo(ctx.User.Id, ctx.Repo.Repository.ID, false)
case "desc":
if !ctx.Repo.IsOwner() {
ctx.Error(404)

View file

@ -160,7 +160,7 @@ func SettingsPost(ctx *middleware.Context, form auth.RepoSettingForm) {
return
}
if err := models.DeleteRepository(ctx.Repo.Owner.Id, ctx.Repo.Repository.Id, ctx.Repo.Owner.Name); err != nil {
if err := models.DeleteRepository(ctx.Repo.Owner.Id, ctx.Repo.Repository.ID, ctx.Repo.Owner.Name); err != nil {
ctx.Handle(500, "DeleteRepository", err)
return
}
@ -262,7 +262,7 @@ func Webhooks(ctx *middleware.Context) {
return
}
ws, err := models.GetWebhooksByRepoId(ctx.Repo.Repository.Id)
ws, err := models.GetWebhooksByRepoId(ctx.Repo.Repository.ID)
if err != nil {
ctx.Handle(500, "GetWebhooksByRepoId", err)
return
@ -569,7 +569,7 @@ func getOrgRepoCtx(ctx *middleware.Context) (*OrgRepoCtx, error) {
if _, ok := ctx.Data["RepoLink"]; ok {
return &OrgRepoCtx{
OrgId: int64(0),
RepoId: ctx.Repo.Repository.Id,
RepoId: ctx.Repo.Repository.ID,
Link: ctx.Repo.RepoLink,
NewTemplate: HOOK_NEW,
}, nil
@ -605,7 +605,7 @@ func TriggerHook(ctx *middleware.Context) {
}
return
}
models.HookQueue.AddRepoID(repo.Id)
models.HookQueue.AddRepoID(repo.ID)
}
func GitHooks(ctx *middleware.Context) {
@ -663,7 +663,7 @@ func SettingsDeployKeys(ctx *middleware.Context) {
ctx.Data["Title"] = ctx.Tr("repo.settings")
ctx.Data["PageIsSettingsKeys"] = true
keys, err := models.ListDeployKeys(ctx.Repo.Repository.Id)
keys, err := models.ListDeployKeys(ctx.Repo.Repository.ID)
if err != nil {
ctx.Handle(500, "ListDeployKeys", err)
return
@ -695,7 +695,7 @@ func SettingsDeployKeysPost(ctx *middleware.Context, form auth.AddSSHKeyForm) {
}
}
if err = models.AddDeployKey(ctx.Repo.Repository.Id, form.Title, content); err != nil {
if err = models.AddDeployKey(ctx.Repo.Repository.ID, form.Title, content); err != nil {
ctx.Data["HasError"] = true
switch {
case models.IsErrKeyAlreadyExist(err):
@ -710,7 +710,7 @@ func SettingsDeployKeysPost(ctx *middleware.Context, form auth.AddSSHKeyForm) {
return
}
log.Trace("Deploy key added: %d", ctx.Repo.Repository.Id)
log.Trace("Deploy key added: %d", ctx.Repo.Repository.ID)
ctx.Flash.Success(ctx.Tr("repo.settings.add_key_success", form.Title))
ctx.Redirect(ctx.Repo.RepoLink + "/settings/keys")
}

View file

@ -104,7 +104,7 @@ func Dashboard(ctx *middleware.Context) {
for _, act := range actions {
if act.IsPrivate {
// This prevents having to retrieve the repository for each action
repo := &models.Repository{Id: act.RepoID, IsPrivate: true}
repo := &models.Repository{ID: act.RepoID, IsPrivate: true}
if act.RepoUserName != ctx.User.LowerName {
if has, _ := models.HasAccess(ctx.User, repo, models.ACCESS_MODE_READ); !has {
continue
@ -212,7 +212,7 @@ func Profile(ctx *middleware.Context) {
continue
}
// This prevents having to retrieve the repository for each action
repo := &models.Repository{Id: act.RepoID, IsPrivate: true}
repo := &models.Repository{ID: act.RepoID, IsPrivate: true}
if act.RepoUserName != ctx.User.LowerName {
if has, _ := models.HasAccess(ctx.User, repo, models.ACCESS_MODE_READ); !has {
continue
@ -295,21 +295,21 @@ func Issues(ctx *middleware.Context) {
continue
}
repoIds = append(repoIds, repo.Id)
repoIds = append(repoIds, repo.ID)
repo.NumOpenIssues = repo.NumIssues - repo.NumClosedIssues
issueStats.AllCount += int64(repo.NumOpenIssues)
if isShowClosed {
if repo.NumClosedIssues > 0 {
if filterMode == models.FM_CREATE {
repo.NumClosedIssues = int(models.GetIssueCountByPoster(ctx.User.Id, repo.Id, isShowClosed))
repo.NumClosedIssues = int(models.GetIssueCountByPoster(ctx.User.Id, repo.ID, isShowClosed))
}
showRepos = append(showRepos, repo)
}
} else {
if repo.NumOpenIssues > 0 {
if filterMode == models.FM_CREATE {
repo.NumOpenIssues = int(models.GetIssueCountByPoster(ctx.User.Id, repo.Id, isShowClosed))
repo.NumOpenIssues = int(models.GetIssueCountByPoster(ctx.User.Id, repo.ID, isShowClosed))
}
showRepos = append(showRepos, repo)
}
@ -350,7 +350,7 @@ func Issues(ctx *middleware.Context) {
}
}
issues[i].Repo, err = models.GetRepositoryById(issues[i].RepoID)
issues[i].Repo, err = models.GetRepositoryByID(issues[i].RepoID)
if err != nil {
if models.IsErrRepoNotExist(err) {
log.Warn("GetRepositoryById[%d]: repository not exist", issues[i].RepoID)

View file

@ -17,7 +17,7 @@
<table class="table table-striped">
<thead>
<tr>
<th>Id</th>
<th>ID</th>
<th>{{.i18n.Tr "admin.repos.owner"}}</th>
<th>{{.i18n.Tr "admin.repos.name"}}</th>
<th>{{.i18n.Tr "admin.repos.private"}}</th>
@ -30,7 +30,7 @@
<tbody>
{{range .Repos}}
<tr>
<td>{{.Id}}</td>
<td>{{.ID}}</td>
<td><a href="{{AppSubUrl}}/{{.Owner.Name}}">{{.Owner.Name}}</a></td>
<td><a href="{{AppSubUrl}}/{{.Owner.Name}}/{{.Name}}">{{.Name}}</a></td>
<td><i class="fa fa{{if .IsPrivate}}-check{{end}}-square-o"></i></td>

View file

@ -7,7 +7,7 @@
<div class="divider"> / </div>
<a href="{{$.RepoLink}}">{{.Name}}</a>
{{if .IsMirror}}<div class="ui label">{{$.i18n.Tr "mirror"}}</div>{{end}}
{{if .IsFork}}<div class="fork-flag">{{$.i18n.Tr "repo.forked_from"}} <a href="{{.ForkRepo.RepoLink}}">{{SubStr .ForkRepo.RepoLink 1 -1}}</a></div>{{end}}
{{if .IsFork}}<div class="fork-flag">{{$.i18n.Tr "repo.forked_from"}} <a href="{{.BaseRepo.RepoLink}}">{{SubStr .BaseRepo.RepoLink 1 -1}}</a></div>{{end}}
</div>
</h2>
<div class="ui right floated secondary menu">

View file

@ -7,7 +7,7 @@
<span class="divider">/</span>
<a class="repo text-bold" href="{{$.RepoLink}}">{{.Name}}</a>
{{if .IsMirror}}<span class="label label-gray">{{$.i18n.Tr "mirror"}}</span>{{end}}
{{if .IsFork}}<span class="fork-flag">forked from <a href="{{.ForkRepo.RepoLink}}">{{SubStr .ForkRepo.RepoLink 1 -1}}</a></span>{{end}}
{{if .IsFork}}<span class="fork-flag">forked from <a href="{{.BaseRepo.RepoLink}}">{{SubStr .BaseRepo.RepoLink 1 -1}}</a></span>{{end}}
</h1>
<ul id="repo-header-meta" class="right menu menu-line">
<li id="repo-header-download" class="drop">
@ -49,7 +49,7 @@
</a>
</li>
<li id="repo-header-fork">
<a id="repo-header-fork-btn" {{if or (not $.IsRepositoryAdmin) $.Owner.IsOrganization}}href="{{AppSubUrl}}/repo/fork/{{.Id}}"{{end}}>
<a id="repo-header-fork-btn" {{if or (not $.IsRepositoryAdmin) $.Owner.IsOrganization}}href="{{AppSubUrl}}/repo/fork/{{.ID}}"{{end}}>
<button class="btn btn-gray text-bold btn-radius">
<i class="octicon octicon-repo-forked"></i>{{$.i18n.Tr "repo.fork"}}
<span class="num">{{.NumForks}}</span>

View file

@ -9,11 +9,14 @@
<a class="link" href="{{.Repository.Website}}">{{.Repository.Website}}</a>
</p>
<ul id="repo-file-nav" class="clear menu menu-line">
<!-- <li>
<a href="#">
{{if and .IsRepositoryAdmin .Repository.BaseRepo}}
{{ $baseRepo := .Repository.BaseRepo}}
<li>
<a href="{{AppSubUrl}}/{{$baseRepo.Owner.Name}}/{{$baseRepo.Name}}/compare/{{$.BaseDefaultBranch}}...{{$.Owner.Name}}:{{$.BranchName}}">
<button class="btn btn-green btn-small btn-radius" id="repo-compare-btn"><i class="octicon octicon-git-compare"></i></button>
</a>
</li> -->
</li>
{{end}}
<li id="repo-branch-switch" class="down drop">
<a>
<button class="btn btn-gray btn-medium btn-radius">

View file

@ -0,0 +1,51 @@
{{template "base/head" .}}
<div class="repository compare pull">
{{template "repo/header" .}}
<div class="ui middle page grid body">
<div class="sixteen wide column page grid">
<h2 class="ui header">
{{.i18n.Tr "repo.pulls.compare_changes"}}
<div class="sub header">{{.i18n.Tr "repo.pulls.compare_changes_desc"}}</div>
</h2>
<div class="ui segment choose branch">
<span class="octicon octicon-git-compare"></span>
<div class="ui floating filter dropdown">
<div class="ui basic small button">
<span class="text">base: {{$.BaseBranch}}</span>
<i class="dropdown icon"></i>
</div>
<div class="menu">
<div class="ui icon search input">
<i class="filter icon"></i>
<input name="search" placeholder="Filter branch...">
</div>
<div class="items">
{{range .Branches}}
<a class="{{if eq $.BaseBranch .}}active selected{{end}} item" href="{{$.RepoLink}}/compare/{{.}}...{{$.SignedUser.Name}}:{{$.HeadBranch}}">{{.}}</a>
{{end}}
</div>
</div>
</div>
...
<div class="ui floating filter dropdown">
<div class="ui basic small button">
<span class="text">compare: {{$.HeadBranch}}</span>
<i class="dropdown icon"></i>
</div>
<div class="menu">
<div class="ui icon search input">
<i class="filter icon"></i>
<input name="search" placeholder="Filter branch...">
</div>
<div class="items">
{{range .HeadBranches}}
<a class="{{if eq $.HeadBranch .}}active selected{{end}} item" href="{{$.RepoLink}}/compare/{{$.BaseBranch}}...{{$.SignedUser.Name}}:{{.}}">{{.}}</a>
{{end}}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{{template "base/footer" .}}