Add option to delete branch after pr got merged #929

Merged
mmarif merged 10 commits from qwerty287/GitNex:delete-branch into main 2 weeks ago

Describe what your pull request does and which issue you’re targeting

Closes #860


### Describe what your pull request does and which issue you’re targeting <!-- Create a new issue, if it doesn't exist yet --> Closes #860 <br><br> <!-- Make sure you are targeting the "main" branch, pull requests on release branches are only allowed for bug fixes. --> - [X] I carefully read the [contribution guidelines](https://codeberg.org/GitNex/GitNex/src/branch/main/CONTRIBUTING.md). - [X] I'm following the code standards as defined [here](https://codeberg.org/gitnex/GitNex/wiki/Code-Standards). - [X] By submitting this pull request, I permit GitNex to license my work under the [GNU General Public License v3](https://codeberg.org/GitNex/GitNex/src/branch/main/LICENSE).
qwerty287 added 1 commit 3 weeks ago
opyale added the
Enhancement
label 3 weeks ago
Poster

(Just FYI this is and was already ready for review)

(Just FYI this is and was already ready for review)
6543 added this to the 4.0.0 milestone 2 weeks ago
Owner

@qwerty287 Here are some imprvoments to be made after my initial review:

  • Create an Action class in actions package with a name PullRequestActions.
  • Move all the logic from Bottomsheet to PullRequestActions.

Here are some examples:

Action class method

Calling action class method from bottomsheet

@qwerty287 Here are some imprvoments to be made after my initial review: - Create an Action class in `actions` package with a name `PullRequestActions`. - Move all the logic from Bottomsheet to `PullRequestActions`. Here are some examples: [Action class method](https://codeberg.org/gitnex/GitNex/src/branch/main/app/src/main/java/org/mian/gitnex/actions/IssueActions.java#L25) [Calling action class method from bottomsheet](https://codeberg.org/gitnex/GitNex/src/branch/main/app/src/main/java/org/mian/gitnex/fragments/BottomSheetSingleIssueFragment.java#L172)
Collaborator

Create an Action class in actions package with a name PullRequestActions.

You could also just create a ViewModel.

> Create an Action class in ``actions`` package with a name ``PullRequestActions``. You could also just create a ``ViewModel``.
qwerty287 added 2 commits 2 weeks ago
Poster

I moved the delete branch method to the pull request actions class, but I can't move more things. Most of the actions aren't pr-specific and also moved to the IssueActions.

I moved the delete branch method to the pull request actions class, but I can't move more things. Most of the actions aren't pr-specific and also moved to the IssueActions.
Poster

Btw, maybe you know it already, but the CI actions always fail

Running with gitlab-runner 13.12.0-rc1 (b21d5c5b)
  on docker-auto-scale 72989761
  feature flags: FF_GITLAB_REGISTRY_HELPER_IMAGE:true, FF_SKIP_DOCKER_MACHINE_PROVISION_ON_CREATION_FAILURE:true
Resolving secrets 00:00
Preparing the "docker+machine" executor 00:07
Using Docker executor with image curlimages/curl:7.76.1 ...
Pulling docker image curlimages/curl:7.76.1 ...
Using docker image sha256:bbadf782a297d4373dc4efd44b7877040b75e661e44adca59595c9148adc6f81 for curlimages/curl:7.76.1 with digest curlimages/curl@sha256:fa32ef426092b88ee0b569d6f81ab0203ee527692a94ec2e6ceb2fd0b6b2755c ...
Preparing environment 00:01
Running on runner-72989761-project-19824009-concurrent-0 via runner-72989761-srm-1623008112-6c1fad81...
Getting source from Git repository 00:02
$ eval "$CI_PRE_CLONE_SCRIPT"
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/opyale/gitnex/.git/
Created fresh repository.
Checking out 0fc845e0 as main...
Skipping Git submodules setup
Executing "step_script" stage of the job script 00:01
Using docker image sha256:bbadf782a297d4373dc4efd44b7877040b75e661e44adca59595c9148adc6f81 for curlimages/curl:7.76.1 with digest curlimages/curl@sha256:fa32ef426092b88ee0b569d6f81ab0203ee527692a94ec2e6ceb2fd0b6b2755c ...
$ ./scripts/add-commit-status.sh
sh: eval: line 121: ./scripts/add-commit-status.sh: not found
Cleaning up file based variables 00:00
ERROR: Job failed: exit code 127

e.g. https://gitlab.com/opyale/gitnex/-/jobs/1322447387

Btw, maybe you know it already, but the CI actions always fail ``` Running with gitlab-runner 13.12.0-rc1 (b21d5c5b) on docker-auto-scale 72989761 feature flags: FF_GITLAB_REGISTRY_HELPER_IMAGE:true, FF_SKIP_DOCKER_MACHINE_PROVISION_ON_CREATION_FAILURE:true Resolving secrets 00:00 Preparing the "docker+machine" executor 00:07 Using Docker executor with image curlimages/curl:7.76.1 ... Pulling docker image curlimages/curl:7.76.1 ... Using docker image sha256:bbadf782a297d4373dc4efd44b7877040b75e661e44adca59595c9148adc6f81 for curlimages/curl:7.76.1 with digest curlimages/curl@sha256:fa32ef426092b88ee0b569d6f81ab0203ee527692a94ec2e6ceb2fd0b6b2755c ... Preparing environment 00:01 Running on runner-72989761-project-19824009-concurrent-0 via runner-72989761-srm-1623008112-6c1fad81... Getting source from Git repository 00:02 $ eval "$CI_PRE_CLONE_SCRIPT" Fetching changes with git depth set to 50... Initialized empty Git repository in /builds/opyale/gitnex/.git/ Created fresh repository. Checking out 0fc845e0 as main... Skipping Git submodules setup Executing "step_script" stage of the job script 00:01 Using docker image sha256:bbadf782a297d4373dc4efd44b7877040b75e661e44adca59595c9148adc6f81 for curlimages/curl:7.76.1 with digest curlimages/curl@sha256:fa32ef426092b88ee0b569d6f81ab0203ee527692a94ec2e6ceb2fd0b6b2755c ... $ ./scripts/add-commit-status.sh sh: eval: line 121: ./scripts/add-commit-status.sh: not found Cleaning up file based variables 00:00 ERROR: Job failed: exit code 127 ``` e.g. https://gitlab.com/opyale/gitnex/-/jobs/1322447387
mmarif requested changes 2 weeks ago
import org.mian.gitnex.helpers.Toasty;
import retrofit2.Call;
import retrofit2.Callback;
mmarif commented 2 weeks ago
Poster
Owner

You can add yourself as author here(blank line up, below).

You can add yourself as author here(blank line up, below).
qwerty287 marked this conversation as resolved
public class PullRequestActions {
public static void deleteHeadBranch(@NonNull Context context, String repoOwner, String repoName, String headBranch, boolean showToasts) {
mmarif commented 2 weeks ago
Poster
Owner

Remove @NonNull.

Remove @NonNull.
qwerty287 marked this conversation as resolved
.getApiInterface(context)
.deleteBranch(Authorization.get(context), repoOwner, repoName, headBranch);
call.enqueue(new Callback<JsonElement>() {
mmarif commented 2 weeks ago
Poster
Owner

Push this back one tab for proper alignment.

Push this back one tab for proper alignment.
qwerty287 marked this conversation as resolved
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
if(showToasts) Toasty.error(context, context.getString(R.string.deleteBranchError));
Log.i("onFailure", t.toString());
mmarif commented 2 weeks ago
Poster
Owner

This is not needed, you can remove it.

This is not needed, you can remove it.
qwerty287 marked this conversation as resolved
}
private void deleteBranchFunction(String repoOwner, String repoName) {
mmarif commented 2 weeks ago
Poster
Owner

Nice touch by removing this.

Nice touch by removing this.
qwerty287 marked this conversation as resolved
deletePullRequestBranch.setOnClickListener(v -> {
assert ctx != null;
mmarif commented 2 weeks ago
Poster
Owner

Remove assert for ctx. To make this work, you can also remove @NonNull from the Context in PullRequestActions.

Remove assert for ctx. To make this work, you can also remove @NonNull from the Context in PullRequestActions.
qwerty287 marked this conversation as resolved
qwerty287 added 5 commits 2 weeks ago
qwerty287 added 1 commit 2 weeks ago
Poster

I found two settings string arrays (cache size) that aren't in the settings.xml, is it ok if I push them into this branch/pr?

I found two settings string arrays (cache size) that aren't in the settings.xml, is it ok if I push them into this branch/pr?
Owner

Sure, go ahead.

Sure, go ahead.
qwerty287 added 1 commit 2 weeks ago
mmarif approved these changes 2 weeks ago
Collaborator

Btw, maybe you know it already, but the CI actions always fail

Yes, don't worry, I will fix it soon. 🙂

> Btw, maybe you know it already, but the CI actions always fail Yes, don't worry, I will fix it soon. 🙂
mmarif merged commit d567a012d8 into main 2 weeks ago

Reviewers

mmarif approved these changes 2 weeks ago
The pull request has been merged as d567a012d8.
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date

No due date set.

Dependencies

This pull request currently doesn't have any dependencies.

Loading…
There is no content yet.