Skip to content

Commit 7bb89e6

Browse files
committed
feat: add reposotory id in commit/tag/tree table
1 parent 068343b commit 7bb89e6

20 files changed

+468
-256
lines changed

api/jiaozifs.gen.go

Lines changed: 117 additions & 63 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/swagger.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,11 @@ paths:
595595
operationId: getObject
596596
summary: get object content
597597
parameters:
598+
- in: query
599+
name: isWip
600+
description: isWip indicate to retrieve from working in progress, default false
601+
schema:
602+
type: boolean
598603
- in: header
599604
name: Range
600605
description: Byte range to retrieve
@@ -666,6 +671,11 @@ paths:
666671
operationId: headObject
667672
summary: check if object exists
668673
parameters:
674+
- in: query
675+
name: isWip
676+
description: isWip indicate to retrieve from working in progress, default false
677+
schema:
678+
type: boolean
669679
- in: header
670680
name: Range
671681
description: Byte range to retrieve

controller/commit_ctl.go

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ func (commitCtl CommitController) GetEntriesInRef(ctx context.Context, w *api.Ji
5858
return
5959
}
6060

61-
commit, err := commitCtl.Repo.CommitRepo().Commit(ctx, ref.CommitHash)
61+
commit, err := commitCtl.Repo.CommitRepo(repository.ID).Commit(ctx, ref.CommitHash)
6262
if err != nil {
6363
w.Error(err)
6464
return
6565
}
6666

67-
workTree, err := versionmgr.NewWorkTree(ctx, commitCtl.Repo.FileTreeRepo(), models.NewRootTreeEntry(commit.TreeHash))
67+
workTree, err := versionmgr.NewWorkTree(ctx, commitCtl.Repo.FileTreeRepo(repository.ID), models.NewRootTreeEntry(commit.TreeHash))
6868
if err != nil {
6969
w.Error(err)
7070
return
@@ -82,14 +82,26 @@ func (commitCtl CommitController) GetEntriesInRef(ctx context.Context, w *api.Ji
8282
w.JSON(treeEntry)
8383
}
8484

85-
func (commitCtl CommitController) GetCommitDiff(ctx context.Context, w *api.JiaozifsResponse, _ *http.Request, ownerName string, _ string, basehead string, params api.GetCommitDiffParams) {
85+
func (commitCtl CommitController) GetCommitDiff(ctx context.Context, w *api.JiaozifsResponse, _ *http.Request, ownerName string, repositoryName string, basehead string, params api.GetCommitDiffParams) {
8686
operator, err := auth.GetOperator(ctx)
8787
if err != nil {
8888
w.Error(err)
8989
return
9090
}
9191

92-
if operator.Name == ownerName { //todo check permission
92+
owner, err := commitCtl.Repo.UserRepo().Get(ctx, models.NewGetUserParams().SetName(ownerName))
93+
if err != nil {
94+
w.Error(err)
95+
return
96+
}
97+
98+
repository, err := commitCtl.Repo.RepositoryRepo().Get(ctx, models.NewGetRepoParams().SetName(repositoryName).SetOwnerID(owner.ID))
99+
if err != nil {
100+
w.Error(err)
101+
return
102+
}
103+
104+
if operator.ID == owner.ID { //todo check permission
93105
w.Forbidden()
94106
return
95107
}
@@ -111,7 +123,7 @@ func (commitCtl CommitController) GetCommitDiff(ctx context.Context, w *api.Jiao
111123
return
112124
}
113125

114-
bashCommit, err := commitCtl.Repo.CommitRepo().Commit(ctx, bashCommitHash)
126+
bashCommit, err := commitCtl.Repo.CommitRepo(repository.ID).Commit(ctx, bashCommitHash)
115127
if err != nil {
116128
w.Error(err)
117129
return
@@ -122,7 +134,7 @@ func (commitCtl CommitController) GetCommitDiff(ctx context.Context, w *api.Jiao
122134
path = *params.Path
123135
}
124136

125-
commitOp := versionmgr.NewCommitOp(commitCtl.Repo, bashCommit)
137+
commitOp := versionmgr.NewCommitOp(commitCtl.Repo, repository.ID, bashCommit)
126138
changes, err := commitOp.DiffCommit(ctx, toCommitHash)
127139
if err != nil {
128140
w.Error(err)

0 commit comments

Comments
 (0)