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

First implementation of git appraise #733

Closed
wants to merge 6 commits into from

Conversation

sokolovstas
Copy link

Issue #189

This is first implementation of appraise review. I opened gitea code only this morning and to end of day I completed showing review list.

Dear maintainers please see the code and tell me if I started implementation properly. I can continue to implement this tomorrow.

@lunny lunny added this to the 1.1.0 milestone Jan 23, 2017
@lunny lunny added the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label Jan 23, 2017
Copy link
Member

@lunny lunny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost it's great!

@@ -0,0 +1,103 @@
// Copyright 2014 The Gogs Authors. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2017 The Gitea

}

// Review struct to Issue representation
type Review struct {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not based on Issue like Pull, so that we can list all issues/pulls/reviews of one milestone.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried but I need that index field will be string, because appraise doesn't have unique in index

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

index's unique could be changed to index I think.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but it is int. In appraise that all we have is string
Revision: b9f1a3d0a1081a5f159ed90a3d413320890e0986

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added IsReview flag on Issue

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you can ignore index field and add revision in Reivew struct.

UpdatedUnix int64
IsClosed bool
IsRead bool
IsPull bool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IsPull needed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this may be removed, thank you

"strings"
"time"

"github.com/google/git-appraise/repository"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Local imports (e.g. code.gitea.io/gitea/foo/bar) should come before non-stdlib external packages (e.g. github.com/foo/bar).

import (
	"strconv"
	"strings"
	"time"

	"code.gitea.io/gitea/models"
	"code.gitea.io/gitea/modules/base"
	"code.gitea.io/gitea/modules/context"

	"github.com/google/git-appraise/repository"
	"github.com/google/git-appraise/review"
)


ctx.Data["Title"] = ctx.Tr("repo.reviews")
ctx.Data["PageIsReviewList"] = true
// ctx.Data["Page"] = 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really needed to add the commented code to repo?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I upload PR to other contributors and maintainers check my code for right implementation to exist code base. I will clear all commented lines on last commit.

@lunny
Copy link
Member

lunny commented Jan 25, 2017

Maybe needs to insert or update one record to issue table when a review request pushed to git?

@tboerger tboerger added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jan 25, 2017
Add commits list
Add comments list
Add GetIndex to models.Issue to return Revision/Index
ctx.Data["Username"] = ctx.Repo.Owner.Name
ctx.Data["Reponame"] = ctx.Repo.Repository.Name

reviewCommits, err := repo.ListCommitsBetween(reviewDetails.Request.TargetRef, reviewDetails.Request.ReviewRef)
Copy link

@ojarjur ojarjur Jan 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic for getting the commits in a review is a little more complicated than this because there are multiple states a review can be in (open, submitted, abandoned, etc).

I have a PR to git-appraise to make this a first-class part of the review API: google/git-appraise#70

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ojarjur thank you, I change usage of this function as soon as it was merged

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sokolovstas That change has been merged into git-appraise now.

@strk
Copy link
Member

strk commented Jan 26, 2017

How can I test this ? I've a repository in which git appraise list shows there is a pending review for commit 09d5b03a69f3, which I've pushed to gitea-hosted git repo with git push gitea-remote --all. Am I supposed to see the comments inline now, on the commit page ? Because I don't see it

@strk strk mentioned this pull request Jan 26, 2017
2 tasks
@rikvdh
Copy link

rikvdh commented Jan 26, 2017

I've just tested this out and it is a good start. Since we don't have line-annotations (#124) (like github does) perhaps just display line/file of a comment when it is present. Also rejection/acceptation is nice to have. Now it is just depicted as a regular comment.

Good work already, good to see the appraise comments in gitea already!

@strk
Copy link
Member

strk commented Jan 28, 2017

@rikvdh as I could not see those comments instead, could you upload a screenshot ?

@ojarjur
Copy link

ojarjur commented Jan 28, 2017 via email

@rikvdh
Copy link

rikvdh commented Jan 29, 2017

Here are some screenshots including the latest commit.

request
The request uses the same template as an issue/pr, the review-request should probably get its own template and have <name> requested review <time ago> instead of commented, also all edit and delete buttons don't work and should be removed.

comments
All comments seem to get a empty code-snippet at the top, also issues and pull-request comments. When there is no line-file information the code-snippet box should be removed i guess.

When having a file/line reference perhaps add the name of the file, it is missing now and on big-reviews this can become very confusing.

The close and comment on the bottom seem to affect my pull-request 1 which is the only one in my test-repo.

Also abandoned reviews (git appraise abandon) should probably close the review, which are now unclose-able. The mutations like accept, reject and abandon are not clear.

Sorry for being so critical, I would really love this feature in Gitea, having a full reviewing system integrated is golden! 👍 Keep up the good work!

@bkcsoft
Copy link
Member

bkcsoft commented Jan 29, 2017

How would this work if a read-only user wants to use git-appraise instead of ?

  • Can they still push their review? Or can only users with write-access do that?
  • If they can, how do you handle authorization? Adding that kind of complexity (checking for notes/dev-refs) sounds like inviting security issues 🙁

Note: I'm very much against implementing something that only some people can use, if we go with git-appraise it should still work just like using the WebUI. In other words, if you can review in the WebUI you can also use git-appraise

My 2 cents 😉

@bkcsoft
Copy link
Member

bkcsoft commented Jan 29, 2017

<name> requested review <time ago> instead of commented

I would say <name> reviewed <timeAgo> 🙂

@ojarjur
Copy link

ojarjur commented Jan 30, 2017

@bkcsoft

How would this work if a read-only user wants to use git-appraise instead of ?

I assume you mean how does this work if someone who does not have write access to a repo wants to use the git-appraise command line tool rather than the gitea UI.

The answer is that user would be able to pull reviews from the repository, but not push them to it. They could always push the review to their fork, but not to the upstream repository.

The git-appraise command-line tool uses the same auth mechanisms as git itself, so a user who cannot push directly to the repo also cannot directly push reviews.

One of the reasons for this design is that tools like gitea already define a way for outside contributors to authenticate and participate in a review, so git-appraise doesn't try to invent its own. Instead, whatever tool is responsible for auth (e.g. gitea) is also responsible for writing the review metadata to the repository.

So what I would expect is that the outside contributor creates their reviews and comments on them via the gitea UI, and the gitea server then writes them to the git-appraise formats.

if we go with git-appraise it should still work just like using the WebUI. In other words, if you can review in the WebUI you can also use git-appraise

The important thing about git-appraise isn't the command-line tool but rather the storage formats.

Even if no one performs code reviews via the command line, having the review metadata stored directly in git is valuable.

@strk
Copy link
Member

strk commented Jan 31, 2017

@ojarjur ok now I see the "Reviews" tab (I just didn't notice before).
Should these "Reviews" be associated to commits/pr rather than having their own tab ?

@roblabla
Copy link
Contributor

roblabla commented Feb 2, 2017

@ojarjur would it not be possible to accept push to the git appraise reference by anyone that has read access to the repo ?

@lunny
Copy link
Member

lunny commented Feb 2, 2017

conflicted

@ojarjur
Copy link

ojarjur commented Feb 2, 2017

would it not be possible to accept push to the git appraise reference by anyone that has read access to the repo

@roblabla It should be possible to achieve what you want, but I would recommend a different implementation than that.

Reviews in git-appraise are just git objects the same way that commits are, and there is a well-established way for read-only contributors to push their own git objects. Specifically, they create a fork of the repository and then push to that fork. Those objects can then be mirrored into the upstream repository in a controlled way (e.g. like GitHub's 'refs/pull/...' refs).

The earlier question from @bkcsoft caused me to start thinking that we could build in a corresponding workflow for git-appraise, and I've created an issue for that here. Please add comments to that issue if the workflow described there doesn't match what you are looking for.

@strk
Copy link
Member

strk commented Mar 12, 2017

I'd love to see this completed too @sokolovstas -- any chance ?
Or anyone else would like to continue where he left ?

@lunny
Copy link
Member

lunny commented Mar 20, 2017

@sokolovstas if you have no time for this, maybe you can allow maintainers or others to continue the work so that you can check Allow edits from maintainers. on this page right bar bottom.

@sokolovstas
Copy link
Author

@lunny This check box is already checked. For now I have very busy on main project and don't have free time. But will be very glad if someone can continue this work!

@strk
Copy link
Member

strk commented Mar 20, 2017 via email

@lunny
Copy link
Member

lunny commented Mar 21, 2017

Maybe but I have to finish my PR first.

@Rushmead
Copy link

Rushmead commented Apr 1, 2017

I've read through the comments and would love to help out with this and get it ready to be merged. Could someone make a list of exact things that need to be changed / added?

@strk
Copy link
Member

strk commented Apr 1, 2017 via email

@lunny lunny modified the milestones: 1.x.x, 1.2.0 Apr 19, 2017
@KangoV
Copy link

KangoV commented May 19, 2017

Any movement on this one? I don't know GO, but I could help with testing and feedback.

@lunny
Copy link
Member

lunny commented May 19, 2017

@KangoV it's not finished and no one continue with this now.

@lafriks
Copy link
Member

lafriks commented May 19, 2017

I could probably work on this as I need it myself :)

@lunny
Copy link
Member

lunny commented May 20, 2017

@lafriks great news, please go ahead.

@strk
Copy link
Member

strk commented May 28, 2017

@lafriks you are very welcome !

@monnier monnier mentioned this pull request Jun 12, 2017
7 tasks
@strk
Copy link
Member

strk commented Jul 13, 2017

This PR is in the wrong milestone, should be 1.3.0 (or 1.4.0, depending on @lafriks estimate)

@strk
Copy link
Member

strk commented Jul 13, 2017

please disregard my previous comment, 1.x.x is clearly undefined but in the 1.x branch...

@lafriks
Copy link
Member

lafriks commented Jul 14, 2017

@strk It's on my todo list just after more advanced branch protection and PR approval system :)

@jonasfranz
Copy link
Member

@lafriks Is theire any further news about this PR or is it replaced by another PR-approval system in future?

@lafriks
Copy link
Member

lafriks commented Aug 31, 2017

I started to work on this but I did not like it how it is currently implemented. I think it should be rewritten to be integrated with PRs

@lunny
Copy link
Member

lunny commented Sep 1, 2017

@lafriks I think rewrite is a better idea.

@techknowlogick
Copy link
Member

Closing this due to PR approval/comment/review system in place via other PR.

@bkcsoft bkcsoft added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Oct 29, 2018
@lunny lunny removed this from the 1.x.x milestone Oct 29, 2018
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/need 1 This PR needs approval from one additional maintainer to be merged. type/feature Completely new functionality. Can only be merged if feature freeze is not active.
Projects
None yet
Development

Successfully merging this pull request may close these issues.