Skip to content

agit flow add refs/for-review/<pull index> support #31245

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

a1012112796
Copy link
Member

@a1012112796 a1012112796 commented Jun 4, 2024

As title, follow #14295

it can be used by author to update pull by pull index
and also can be used by mainter if the Allow edits by maintainers option was enabled.

Documentation ref: https://git-repo.info/en/2020/03/agit-flow-git-repo/

Signed-off-by: a1012112796 <1012112796@qq.com>
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jun 4, 2024
@github-actions github-actions bot added modifies/go Pull requests that update Go code modifies/cli PR changes something on the CLI, i.e. gitea doctor or gitea admin modifies/templates This PR modifies the template files labels Jun 4, 2024
@lunny
Copy link
Member

lunny commented Sep 18, 2024

Can you give some official documentation links for this new refs?

@a1012112796
Copy link
Member Author

Can you give some official documentation links for this new refs?

image

@@ -36,6 +36,75 @@ func ProcReceive(ctx context.Context, repo *repo_model.Repository, gitRepo *git.
return nil, fmt.Errorf("failed to get user. Error: %w", err)
}

updateExistPull := func(pr *issues_model.PullRequest, i int) error {
Copy link
Member

Choose a reason for hiding this comment

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

How about using a normal function?

Copy link
Member Author

Choose a reason for hiding this comment

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

@lunny how about e371a21 ?

@hiifong
Copy link
Member

hiifong commented Dec 26, 2024

if author not enabled Allow edits by maintainers, owner cannot update pr, need more friendly prompt.

hiifong@ubuntu:~/workspace/tmp/gitea$ git push origin HEAD:refs/for-review/2
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 307 bytes | 307.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
remote: 
remote: Gitea: Unknow pull request.
remote: Gitea: HookPreReceive(last) failed: internal API error response, status=403
To http://192.168.133.128:3000/hiifong/gitea.git
 ! [remote rejected]       HEAD -> refs/for-review/2 (pre-receive hook declined)
error: failed to push some refs to 'http://192.168.133.128:3000/hiifong/gitea.git'

@@ -238,7 +238,8 @@ func runServ(c *cli.Context) error {
if git.DefaultFeatures().SupportProcReceive {
// for AGit Flow
if cmd == "ssh_info" {
fmt.Print(`{"type":"gitea","version":1}`)
data := private.GetSSHInfo(ctx)
fmt.Print(data)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
fmt.Print(data)
fmt.Println(data)

Copy link
Contributor

@wxiaoguang wxiaoguang Dec 26, 2024

Choose a reason for hiding this comment

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

Actually, it should use c *cli.Context stdout, to make it testable.

@@ -104,6 +105,12 @@ func (ref RefName) IsFor() bool {
return strings.HasPrefix(string(ref), ForPrefix)
}

var forReviewPattern = regexp.MustCompile(ForReviewPrefix + `[1-9][0-9]*`)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe you need to ensure that the pull index is an integer greater than 0. ^[1-9]\d*$

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. modifies/cli PR changes something on the CLI, i.e. gitea doctor or gitea admin modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants