How to make code suggestion in github/bitbucket? [closed]
Asked Answered
S

3

9

What feature do you use when you want to make a suggestion on the code? Let's say, one of the members think it's better to write a specific part of the code in another way and IF IT'S APPROVED then he/she will implement the actual change?

Spiro answered 29/12, 2014 at 20:11 Comment(1)
Might be helpfull : help.github.com/articles/using-pull-requestsBurchett
A
2

Make a fork and create pull requests. :)

Forking the repository essentially gives you your own workspace on which you can create branches and push, and you can create pull requests from the differences on your fork to the original repository. Pull requests must be approved by the owner of or someone who can write to the original repository.

More information:

Anatomy answered 29/12, 2014 at 20:17 Comment(0)
D
13

In Bitbucket Server (self-hosted edition) you can suggest a change to a single line of the diff at a time by adding a comment that contains:

```suggestion
replacement.line
lets_go.crazy() and a_second.new_line().is_added
```

https://confluence.atlassian.com/bitbucketserver/commenting-on-a-pull-request-1027119882.html

The resulting suggestion can be accepted directly into the PR and looks something like this: Bitbucket Code Suggestion UI

On the Bitbucket Cloud side, the request for this feature can be tracked here.

Dogvane answered 18/5, 2022 at 14:45 Comment(2)
Only works on Bitbucket Server, which you have to host yourself.Nickynico
Wow; I'm kinda in disbelief that Bitbucket Server has features not yet available in the cloud product. Thanks for pointing this out. Updated my answer to clarify.Dogvane
I
12

Since Oct. 2018, you can make "Suggested Changes" in GitHub:

Collaborators can suggest code changes through inline comments in pull requests, and pull request authors can apply, reject, or edit these suggestions as an integrated part of the code review process.

See "Applying a suggested change"

suggested change

See this tweet for illustration.


Update Nov. 2018: the blog post "Suggested changes—what we've learned so far " adds:

Since its release, more than 10 percent of all reviewers suggested at least one change, totaling over 100,000 suggestions—and nearly four percent of all review comments created included a suggestion. Based on these early numbers, we see you’re quick to adopt suggested changes and make them a natural part of your code review workflow.

https://static.mcmap.net/file/mcmap/ZG-AbGLDKwf0bRywKVltWVclbw2nZ7-ocVI0bRywWRfQcFyQcC2jaRA/602352/47467407-41a9a980-d7c4-11e8-9374-acb6a7c43b00.png

By far the most frequent requests were:

  • The ability to suggest changes to multiple lines at once.
  • The ability to accept multiple changes in a single commit.
Inelegancy answered 23/10, 2018 at 21:47 Comment(2)
This should be marked as the correct answer. Not every code change deserves its own pull request or fork, sometimes you just want to make a quick one-liner correction.Yockey
You might be right for a slight part on the fact that not all changes deserves individual pull requests. On the contrary, i think some bugs or system outages are results to those one liners which may have seen harmless at first but had bigger impact. Having a code review for these one liners anyway might just prevent such issues because one could inform you about it beforehand.Dandiprat
A
2

Make a fork and create pull requests. :)

Forking the repository essentially gives you your own workspace on which you can create branches and push, and you can create pull requests from the differences on your fork to the original repository. Pull requests must be approved by the owner of or someone who can write to the original repository.

More information:

Anatomy answered 29/12, 2014 at 20:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.