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

Switch branch Action #286

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aarnapant-sap
Copy link
Contributor

@aarnapant-sap aarnapant-sap commented Jan 3, 2025

Switch Branch Functionality in AbapGit

  • User can now switch branch for the linked repository without explicitly unlinking and relinking.
  • SwitchBranchAction is added to context menu in AbapGitRepository view.
  • added pde tests for switchBranchWizard

@shubhamWaghmare-sap
Copy link
Collaborator

Remove the backlog link from the description. Instead add some description of what the pull request solves.

  • backlog link click here support for branch switching for a linked repository

@@ -101,7 +102,8 @@ public class AbapGitView extends ViewPart implements IAbapGitRepositoriesView {
public static final String ID = "org.abapgit.adt.ui.views.AbapGitView"; //$NON-NLS-1$

protected TableViewer viewer;
protected Action actionRefresh, actionWizard, actionCopy, actionOpen, actionShowMyRepos, actionPullWizard, actionOpenRepository;
protected Action actionRefresh, actionWizard, actionCopy, actionOpen, actionShowMyRepos, actionPullWizard, actionOpenRepository,
actionSwitch;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rename to actionSwitchBranch to avoid ambiguity with other possible actions like switching folder logic.

public SwitchbranchAction(IViewPart view) {
super(Messages.AbapGitView_action_select_branch);
setToolTipText(Messages.AbapGitView_action_select_branch);
setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(AbapGitUIPlugin.PLUGIN_ID, "icons/etool/compare_view.png")); //$NON-NLS-1$
Copy link
Collaborator

Choose a reason for hiding this comment

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

Need to check availability of any other icon.

import org.eclipse.jface.dialogs.DialogPage;
import org.eclipse.jface.dialogs.TrayDialog;

public class AbapGitWizardPageBranchSelectionCredentials extends AbapGitWizardPageRepositoryAndCredentials {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It might be possible to remove this Class & reuse AbapGitWizardPageRepositoryAndCredentials.
This might require to modify the class a little.
To be specific, the following changes could be made to AbapGitWizardPageRepositoryAndCredentials :

  • Add title as a parameter to the constructor.
  • Set the title for the page in the constructor, based on this parameter
  • Remove the existing logic for setting the title & pass the title to be set in the link & pull wizard and also for the new branch selection wizard.

Please try this out and list any issues with this approach.

Comment on lines +173 to +179
if (event.getCurrentPage() == AbapGitWizardBranchSelection.this.pageBranchAndPackage
&& event.getTargetPage() == AbapGitWizardBranchSelection.this.pageCredentials) {
if (AbapGitWizardBranchSelection.this.pageBranchAndPackage.validateAll()) {
event.doit = false;
return;
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Validation of content of current is not needed while going back in the wizard. This logic can be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah true as we won't be navigating it back can remove this.

Comment on lines +9 to +11
public AbapGitWizardPageBranchSelection(IProject project, String destination, CloneData cloneData, Boolean pullAction) {
super(project, destination, cloneData, pullAction);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also set a new title & description for the page. The parent page sets the title "Branch and Package Selection", but the branch selection wizard does not allow to select package.
Hence a new title & description should be set here.

Suggestion.
Title: Select Branch (Same as the credentials page)
Description: Select branch to switch from the dropdown

@@ -0,0 +1,182 @@
package org.abapgit.adt.ui.internal.repositories.wizards;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Move the classes to the package org.abapgit.adt.ui.internal.wizards.
Technically it's right to have repositories in the package name, but presently all wizards & related pages are only related to repositories view.

In future in case we have wizards also for staging view, in that case we can have this new package.

Comment on lines +63 to +69
public Object getProject() {
return this.project;
}

public Object getSelectedRepository() {
return this.selRepoData;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are these methods needed and used anywhere? I don't see its usage.

Comment on lines +52 to +54
if (this.abapGitService == null) {
this.abapGitService = AbapGitUIServiceFactory.createAbapGitService();
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

When the object is created, abapGitService will always be null right?
So, is this check required ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

true that's not required, will remove it.

}
getPackageAndRepoType();

setWindowTitle(Messages.AbapGitView_action_select_branch);
Copy link
Collaborator

Choose a reason for hiding this comment

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

The message variable can be renamed to AbapGitView_action_switch_branch.

Comment on lines +152 to +156
} catch (InvocationTargetException | InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return true;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Show the error message on the page if possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!

@shubhamWaghmare-sap
Copy link
Collaborator

@aarnapant-sap Please also test the solution in a ABAP Cloud system, involving transport requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants