Skip to content
76 changes: 50 additions & 26 deletions activity.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,49 +6,51 @@
Work with your Project 3 team. If you are in a team of 4, form two 2-person teams.

Assign the following roles to the members of your team. If you are in a team
of 2, then both team members will take turns playing the role of the maintainer.
of 2, then each team member will play the role of maintainer for the other's contributions.

Roles:

- Maintainer: Creates and maintains a GitHub project.
- Contributor-1: Contributes to the GitHub project created by the maintainer.
- Contributor-2: Contributes to the GitHub project created by the maintainer.
- Maintainer: Creates and maintains a GitHub repository.
- Contributor-1: Contributes to the GitHub repository created by the maintainer.
- Contributor-2: Contributes to the GitHub repository created by the maintainer.

## Overview

In this activity your team will play out several scenarios of concurrent development with GitHub.

## Setup the project

- Help your maintainer to create a new project on GitHub named `favorites` and add the other team members as contributors.
- Help the maintainer to create a new team and repository through GitHub Classroom. Do not join my TEST team.
https://classroom.github.com/group-assignment-invitations/e592a0be645631543daeb5262a857163

## Contributor-1 setup

- Help Contributor-1 to [clone](https://netbeans.org/kb/docs/ide/git.html#clone) the project in NetBeans.
- Help Contributor-1 to [clone](https://netbeans.org/kb/docs/ide/git.html#clone) the repository in NetBeans. It is pre-populated with a basic NetBeans project named Favorites.

## First contribution

Help contributor-1 to follow the [GitHub flow](https://guides.github.com/introduction/flow/):
- [Create a new branch.](https://netbeans.org/kb/docs/ide/git.html#branchCreate)
- Create a new file `favorite-foods.txt` that contains a couple of contributor-1's
favorite foods.
- [Add and commit the new file.](https://netbeans.org/kb/docs/ide/git.html#add)
- [Create a new development branch.](https://netbeans.org/kb/docs/ide/git.html#branchCreate)
- Edit Main.java to make the main method print out a few favorite foods.
- [Commit](https://netbeans.org/kb/docs/ide/git.html#committing) the changes.
- [Push](https://netbeans.org/kb/docs/ide/git.html#push) the new branch to GitHub.
- On GitHub, [make a pull request](https://help.github.com/articles/creating-a-pull-request/) to pull the new branch into the master branch.

Help the maintainer to [merge contributor-1's pull request](https://help.github.com/articles/merging-a-pull-request/) on GitHub and then [delete the branch](https://help.github.com/articles/deleting-unused-branches/).
Good GitHub practice: *Never merge your own pull request.* Another team member should review your code.

Help contributor-1 to switch to the master branch and [pull changes](https://netbeans.org/kb/docs/ide/git.html#pull) from the remote master. Then, clean up by [deleting the local development branch](https://netbeans.org/kb/docs/ide/git.html#branchDelete).
Help the maintainer to [merge contributor-1's pull request](https://help.github.com/articles/merging-a-pull-request/) on GitHub and then [delete the branch](https://help.github.com/articles/deleting-unused-branches/) on GitHub.

Help contributor-1 to switch to their local master branch and [pull changes](https://netbeans.org/kb/docs/ide/git.html#pull) from the remote master. Use the **Team > Remote > Pull...** dialog, click **Enable Deletes**, and allow it to delete the local clone of the remote development branch.

Then, clean up by [deleting the local development branch](https://netbeans.org/kb/docs/ide/git.html#branchDelete).

Congratulations, your team has made its first contribution! Celebrate.


## Contributor-2 setup and second contribution

- Repeat the steps above to have contributor-2 contribute a new file
`favorite-movies.txt` with a couple of his/her favorite movies.
- Make sure that the maintainer has accepted contributor-2's pull request
and contributor-2 has updated their master and cleaned up.
- Repeat the steps above to have contributor-2 add a few of their favorite foods to the main method of the Main class.
- Make sure that the maintainer has accepted contributor-2's pull request and contributor-2 has updated their master and cleaned up.

Celebrate again.

Expand All @@ -62,34 +64,56 @@ Celebrate. But keep it small. Don't worry, there will be bigger celebrations lat
## Contribute conflicting changes

- Have contributor-1 and contributor-2 independently follow the contribution
workflow to add another favorite food to the end of `favorite-foods.txt`.
- Maintainer, accept one of the pull requests. Try to accept the other. You
workflow to add one more favorite food to the end of the main method.
- Have the maintainer accept maintainer-1's pull request. Try to accept contributor-2's pull request. You
won't be able to because changes in the pull request conflict with the other
that you already accepted.
- Help the contributor with the unresolved pull request to pull changes from GitHub
to the local master and rebase their development branch. Then push
the development branch to GitHub.
- Help contributor-2 switch to rebase their development branch relative to the updated master branch. Close Netbeans and open a terminal.
```bash
$ cd NetBeansProjects/workflow-activity-<teamname> # Your teamname in place of <teamname>, or hit tab
$ git fetch origin master:master
$ git rebase master
$ vi Favorites/src/favorites/Main.java
# or use whatever text editor you prefer to resolve the conflict - call me if you need help
$ git add .
$ git rebase --continue
$ git push -f origin master <BRANCH_NAME>
```
- Contributor-2, check the status of your development branch on GitHub. You should see the merged changes. Now you can open NetBeans again.
- Maintainer, note that the conflicted pull request is automatically updated and
should be acceptable. Accept the pull request.
- Have contributors clean up.
- Have contributors clean up their extra branches.

Celebrate enthusiastically. That was challenging.


## Refactoring

- Have contributor-1 and contributor-2 independently follow the contribution workflow to make the following changes:
- Have contributor-1 add another food to the main method.
- Have contributor-2 make a new static method, movies(), that prints favorite movies. Also move the code to print favorite foods from the main method into a new static method, foods(). Modify the main function to call both methods (and do nothing else).
- Have the maintainer accept maintainer-2's pull request. Try to accept contributor-1's pull request. You
won't be able to because changes in the pull request *really, really* conflict with the other that you already accepted.
- Have contributor-1 pull changes from GitHub into their master branch and rebase their development branch as described above. Then revise the code to put the new favorite food into the new foods() method with the others. Commit and push the changes.
- Have the maintainer accept contributor-2's updated pull request.

Celebrate wildly. That was even more challenging.


## Multi-round contribution

- Have contributor-1 add another food, and contributor-2 another movie.
- Have contributor-1 add another food to the foods() method.
- Have contributor-2 add another movie to the movies() method.
- Have the maintainer ask for a modification through the pull-request
(e.g., "Please pick another flavor. I don't like chocolate.").
- Have contributors make, commit, and push the new changes.
- If the maintainer is satisfied, accept the pull-requests.
- If the maintainer is satisfied, accept the pull requests.
- Contributors, don't forget to clean up.

Notice how pull-requests provide a way for a contributor and a maintainer to
Notice how pull-requests provide a way for team members to
communicate about a proposed change. Also notice how the pull-request updates
automatically as new changes are pushed to the same branch.


## Squash

- Repeat the multi-round contribution until both contributors have made multiple
Expand Down