Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Scout/Contributions for Scout Committers"

(Step 3: Create a local feature branch)
 
(148 intermediate revisions by 10 users not shown)
Line 1: Line 1:
= Contributing a patch or feature =
+
See [[Scout/Contribution/Setup]] and [[Scout/Contribution/Git_Workflows]].
 
+
== Summary ==
+
 
+
Contributing a patch or a new feature to Eclipse Scout Kepler or Luna is done by creating a new feature branch that will be applied to the corresponding develop (currently Luna) or release branch (release/3.9.1 is Kepler SR1). In this chapter all necessary steps are shown to contribute a patch or a feature.
+
This example requires a working EGit installation in the Eclipse IDE.
+
 
+
== Step 1: Clone Git repository ==
+
 
+
All Eclipse Scout Git repositories are listed [http://git.eclipse.org/c/scout/ here]. In this example, we'll provide a new feature to the Scout Runtime. Therefore, we clone the [http://git.eclipse.org/c/scout/org.eclipse.scout.rt.git/ Scout RT] repository.
+
 
+
In your Eclipse IDE click on ''Windows ->  Open Perspective -> Others...'' and select ''Git Repository Exploring''.
+
 
+
[[Image:GitContribution.01.select.git.perspective.png|200px]]
+
 
+
In the GIT perspective, click on ''Clone a Git repository'' and select ''URI'' as a repository source in the next dialog.
+
 
+
[[Image:GitContribution.02.clone.git.perspective.png|200px]]
+
 
+
For the [http://git.eclipse.org/c/scout/org.eclipse.scout.rt.git/ Scout RT repository] we use the SSH URL ssh://git.eclipse.org/gitroot/scout/org.eclipse.scout.rt.git. Please fill in your Eclipse Scout committer credentials in the Username and Password field.
+
 
+
[[Image:GitContribution.03.enter.url.and.credentials.png|200px]]
+
 
+
Since we are interested in the develop and release/3.9.1 (Kepler SR1) branches, we only select these two branches.
+
 
+
[[Image:GitContribution.04.select.remote.branches.png|200px]]
+
 
+
The Scout RT GIT repository will be cloned to a local destination. Select the directory and location to which the GIT repository should be cloned. Choose ''develop'' as the initial branch and enter ''origin'' to reference the remote GIT repository.
+
 
+
[[Image:GitContribution.05.choose.local.destination.png|200px]]
+
 
+
Finally, click on ''Finish'' to clone the Scout RT repository.
+
 
+
 
+
[[Image:GitContribution.06.cloning.repository.png|200px]]
+
 
+
== Step 2: Import Plugins into Workspace ==
+
 
+
After having cloned the Scout RT Git repository, we are going to import all plugins from the repository into our workspace.
+
Double-click on the cloned repository ''org.eclipse.scout.rt'' and right-click on the ''Working Directory'' and select ''Import Projects...''
+
 
+
[[Image:GitContributionStep2.01.import.into.workspace.png|200px]]
+
 
+
In the next step, we import all plugins into our workspace.
+
 
+
[[Image:GitContributionStep2.02.import.into.workspace.wizard.png|200px]]
+
 
+
Click on the ''Next'' button and select all plugins.
+
 
+
[[Image:GitContributionStep2.03.select.plugins.png|200px]]
+
 
+
Click on ''Finish'' to start the import process.
+
 
+
== Step 3: Create a local feature branch ==
+
 
+
For every new feature a separate branch is created.
+
Assume we want to provide an implementation for [https://bugs.eclipse.org/bugs/show_bug.cgi?id=412011 bug 412011]. We will create a local branch first based on the latest commit of the develop branch. Then we apply some initial changes for the bug, commit them to the local branch and will push the local feature branch to the remote Git repository (origin). Afterwards, we will do some further changes, commit them locally and push these changes to the recently created remote branch.
+
 
+
First, we will have a look at the Commit History. In the Git perspective expand your local branches and right click on the ''develop'' branch and choose ''Show In -> History''.
+
 
+
[[Image:GitContributionStep3.01.show.history.png|200px]]
+
 
+
The History view should be opened and it should look something like
+
 
+
[[Image:GitContributionStep3.02.history.timeline.png|200px]]
+
 
+
We can see that our local develop branch (marked in green) refers to the same last commit as the remote develop branch shown as origin/develop in grey. Right-click on the commit where the origin/develop branch is pointing to and select ''Create Branch...''.
+
 
+
[[Image:GitContributionStep3.03.create.branch.png|200px]]
+
 
+
As Source ref or commit we select ''refs/remotes/origin/develop'' and call the local feature branch ''luna_target_bug412011''. Select ''None'' as pull strategy and check ''Checkout new branch''.
+
 
+
[[Image:GitContributionStep3.03.create.new.feature.branch.png|200px]]
+
 
+
Click on ''Finish''. The feature branch should now be created locally.
+
 
+
[[Image:GitContributionStep3.03.feature.branch.created.png|200px]]
+
 
+
The check icon on the left and the bold font in the History view indicate that the feature branch is currently active.
+
 
+
== Step 4: Change Push URL ==
+
 
+
In the previous step we cloned our Scout RT repository from read-only [ssh://git.eclipse.org/gitroot/scout/org.eclipse.scout.rt.git URL]. To be able to push our feature branches and patches, we have to configure the Push URL to use Gerrit where write access is granted.
+
Expand the ''Remotes'' directory, right-click on ''origin'' and select ''Gerrit Configuration...''
+
 
+
[[Image:GitContributionStep4.01.configure.push.url.png]]
+
 
+
For Scout RT, we add the URL ''ssh://[username]@git.eclipse.org:29418/scout/org.eclipse.scout.rt.git'' where [username] should be replaced with your committer ID.
+
 
+
[[Image:GitContributionStep4.02.add.gerrit.png]]
+
+
Click on ''Finish''. Your Push URL should now look similar like
+
 
+
[[Image:GitContributionStep4.03.gerrit.added.png]]
+
 
+
 
+
== Step 5: Push feature branch to remote repository ==
+
 
+
Now we push the recently created local feature branch to the remote repository. Right-click on the local feature branch luna_target_bug412011 and select ''Push Branch...''.
+
 
+
[[Image:GitContributionStep5.01.push.feature.branch.to.remote.png]]
+
 
+
Select the remote repository which correspond to the Gerrit Push URL we've just added in the previous step. Press ''Next''.
+
 
+
[[Image:GitContributionStep5.02.select.remote.repository.png]]
+
 
+
Now we choose the target ref name for the feature branch. The convention is as follow:
+
''refs/heads/features/[committerID]/shortDescription_bug[ID]'', where [committerID] and [ID] should be replaced by the actual value.
+
 
+
[[Image:GitContributionStep5.03.choose.target.ref.name.png]]
+
 
+
Press ''Finish'' and the feature branch should now be pushed onto the remote repository.
+
 
+
[[Image:GitContributionStep5.04.feature.branch.pushed.png]]
+
 
+
The feature branch is visible in the ''Remote Tracking'' directory.
+
 
+
[[Image:GitContributionStep5.05.feature.branch.added.png]]
+
 
+
== Step 6: Commit changes to local feature branch and push to remote repository ==
+
 
+
In our example we made some initial changes for [https://bugs.eclipse.org/bugs/show_bug.cgi?id=412011 bug 412011] and are now about to commit a new file into the local branch. Switch to the view ''Git Staging''.
+
 
+
[[Image:GitContributionStep6.01.commit.to.local.branch.png]]
+
 
+
In the ''Unstaged Changes'' area all new and modified files are listed. We move the new eclipse-3.10I.target to the ''Staged Changes'' area by using drag-and-drop and enter a commit message.
+
 
+
[[Image:GitContributionStep6.02.stage.and.enter.commit.message.png]]
+
 
+
Now we press the button ''Commit'' so that the target file will be committed into the local feature branch (Note: If we pressed the button ''Commit and Push'', we would commit the target file into the local feature branch and also push those changes to the feature branch on the remote repository. However, we will do this step manually in this example).
+
 
+
If we look at the Commit History, we see that the local feature branch ''luna_target_bug412011'' is 1 commit ahead of the remote feature branch ''origin/features/klee1/lunaTarget_bug412011''.
+
 
+
[[Image:GitContributionStep6.03.commit.history.png]]
+
 
+
Next, we push to local feature branch into the feature branch of the remote repository. Right-click on the Scout RT Git repository and select ''Push to Gerrit...''
+
 
+
[[Image:GitContributionStep6.04.push.to.gerrit.png]]
+
 
+
In the ''URI'' field select Gerrit (the one containing git.eclipse.org:29418) and in the field ''Gerrit branch'' select ''refs/for/'' and hit Ctrl+Space in the text field to open a pop-up dialog. Select your remote feature branch and press ''Finish''.
+
 
+
[[Image:GitContributionStep6.05.push.to.gerrit.dialog.png]]
+
 
+
The prefix ''refs/for'' indicates a special branch for Gerrit code review. The changes in the local feature branch will not directly be pushed into the feature branch of the remote repository. Instead, the changes are made available in Gerrit where code review can be done. In our example, the URL for code review is displayed ''Message Details'' box.
+
 
+
[[Image:GitContributionStep6.06.gerrit.url.for.code.review.png]]
+
 
+
This [https://git.eclipse.org/r/14180 URL] can be opened in a browser. The [https://hudson.eclipse.org/sandbox/ Sandbox Hudson] will verify the supplied changes and set the ''verified'' flag if the build was successful.
+
 
+
[[Image:GitContributionStep6.07.gerrit.in.browser.png]]
+
 
+
After reviewing the code, the changes can be merged into the feature branch by clicking on the button ''Review'' and setting ''Code-Review'' +2 and ''IP-Clean'' to +1 and pressing ''Publish and Submit''.
+
 
+
[[Image:GitContributionStep6.08.gerrit.publish.and.submit.png]]
+
 
+
Right-click on the Scout RT Git repository and select ''Fetch from Upstream''.
+
 
+
[[Image:GitContributionStep6.09.fetch.from.upstream.png]]
+
 
+
All branches will be fetched, i.e. our remote feature branch should be updated and be visible in the Commit History.
+
Currently, the local feature branch and the remote feature branch point to different commits, however they both contain the same changes. Therefore, we are going to rebase our local feature branch on top of the remote feature branch. Right-click on the remote feature branch and select ''Rebase on Top of''.
+
 
+
[[Image:GitContributionStep6.10.rebase.png]]
+
 
+
The local feature branch and remote should now point to the same commit ID.
+
 
+
[[Image:GitContributionStep6.11.after.rebase.png]]
+
 
+
== Step 7: Apply commits from feature branch to develop ==
+
 
+
Before we apply our changes from the feature branch to the ''develop'' branch (the development branch of Scout Luna), we decide to make some further changes, commit them into the local feature branch and push them to Gerrit again (please repeat step 6). The new changes for our example are available [https://git.eclipse.org/r/14182 here]. As before, we review and apply these changes into the remote feature branch resulting the Commit History view to display something like this:
+
 
+
[[Image:GitContributionStep7.01.commit.history.png]]
+
 
+
We now have two commits in our feature branch (remote and local) and both of them will be applied to to the origin/develop branch as 1 commit, i.e. in the Git context we squash our 2 commits from the feature branch into 1.
+
To achieve this goal we reset our local feature branch ''luna_target_bug412011'' to the remote ''origin/develop'' branch by right-clicking and select ''Reset -> Mixed (HEAD and Index)''.
+
 
+
[[Image:GitContributionStep7.02.reset.mixed.png]]
+
 
+
Reset-Mixed means that the changes from the feature branch will be made available as ''Unstaged Changes''. In the ''Git Staging'' perspective we move the changes to the ''Staged Changes'' area and commit them locally.
+
 
+
[[Image:GitContributionStep7.03.squash.commit.png]]
+
 
+
The Commit History looks like:
+
 
+
[[Image:GitContributionStep7.04.commit.history.after.commit.png]]
+
 
+
The local feature branch ''luna_target_bug412011'' is now 1 commit ahead of the ''origin/develop'' branch, so we push this commit to Gerrit as follows: Select ''Push to Gerrit...'' and configure the dialog like this:
+
 
+
[[Image:GitContributionStep7.05.push.to.gerrit.develop.branch.png]]
+
 
+
Hit Ctrl+Space in the ''Gerrit Branch'' field and choose ''develop'' branch, select ''refs/for/'' in the drop-down field.
+
After a successful code review at [https://git.eclipse.org/r/14189/ Gerrit], we apply this change into the remote develop branch.
+
 
+
The Commit History should now display a new commit on the ''origin/develop'' branch.
+
 
+
[[Image:GitContributionStep7.06.commit.history.after.merging.png]]
+
 
+
== Step 8: Apply commit from develop to release branch ==
+
 
+
Assume that the changes from the previous feature branch should also be applied to a release branch, e.g. release/3.9.1. Since we squashed our feature branch commits in the ''develop'' branch, we can just cherrypick the commit from the ''develop'' branch.
+
 
+
To do this checkout ''origin/release/3.9.1'' to a local branch by right-clicking on the ''origin/release/3.9.1'' and select ''Create Branch...''
+
 
+
[[Image:GitContributionStep8.01.checkout.release.branch.png]]
+
 
+
The local branch will be named ''release/3.9.1''.
+
 
+
[[Image:GitContributionStep8.02.checkout.release.branch.dialog.png]]
+
 
+
Press ''Finish'' and a new local branch should be visible and active.
+
 
+
[[Image:GitContributionStep8.03.new.local.branch.png]]
+
 
+
We will now pick the commit from ''origin/develop'' that we would also like to have in our release branch 3.9.1. Right-click on the commit ''f3ea51c'' and select ''Cherry Pick''.
+
 
+
[[Image:GitContributionStep8.04.cherrypick.png]]
+
 
+
The changes are automatically applied and committed to the local release branch.
+
 
+
[[Image:GitContributionStep8.05.commit.history.after.cherrypick.png]]
+
 
+
As explained in step 7, we can push these changes to Gerrit. Right-click on the Scout RT Git repository and select ''Push to Gerrit...'' Enter ''release/3.9.1'' in the ''Gerrit Branch'' field ans select ''refs/for/'' as before.
+
 
+
[[Image:GitContributionStep8.06.push.to.gerrit.release.branch.png]]
+
 
+
Press ''Finish'' and follow the same procedure as described in step 7 for applying the changes in Gerrit to the remote release branch.
+
Note: We abandon the [https://git.eclipse.org/r/14193 change] since this feature is only intended for Scout 3.10 and not for the release branch 3.9.1. However, the main message how to apply changes from the ''develop'' to a release branch should be clear.
+

Latest revision as of 04:27, 18 August 2014

See Scout/Contribution/Setup and Scout/Contribution/Git_Workflows.

Back to the top