Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

How about good ol' patches? We still accept them, so if you prefer using the patch approach you can are welcome to create and submit patches.

Prerequisites

  1. Git
  2. Maven3
  3. Java7Java8
  4. Sign CLA

Setup

There are a couple of steps to set things up the first time:

Step 1: Create a free GitHub account if you don't already have one. Be sure to set up your account with a SSH key pair and your email address(es) so Git can identify which commits are yours.
Step 2: Go to the ModeShape Fedora repository on GitHub and click on the "Fork" button
Step 3: Clone your fork, using the private URLthe Fedora repository. At a command line, go to a directory where you want the new local repository, and issue the following: 

Code Block
$ git clone 

...

https://github.com

...

/fcrepo4/

...

fcrepo4.git

 

This can take as long as a minute or two. But when it does finish you'll When this finishes you will have a local clone of your forkthe Fedora code base, complete with a remote named 'origin' that points back to your fork on GitHub (not the original). to the main Fedora Github repository.

Step 4: Tell your local clone about your fork of the official upstream repository on GitHub: 

Code Block
$ cd

...

 fcrepo4
$ git remote

...

 add <you> https://github.com/

...

<you>/

...

fcrepo4.git

$ git fetch upstream

 

This uses the public URL for the upstream repository, which is read-only. This helps ensure that your changes only go into your fork repository.

 

Now we've set up a local Git repository, we can talk about the steps you'll do much more often.

 

Pulling Upstream Changes

Start by ensuring that you 're are on the 'master' branch and that you 've got have no local changes: 

Code Block
$ git checkout master

...


$ git status

...

The last command should report something like: 

Code Block
# On branch master

...


nothing to commit (working directory clean)

...

Now, we need to pull any changes made to the official upstream main repository due to new features or bug fixes. You can pull them into your fork two ways: 

Code Block
$ git pull

...

 

or

 

...

$ git merge upstream/master

 

The first is more direct, but it only gets the changes for one branch ("master" in this case) and because the merge is not explicit it can be confusing for new Git users that the 'pull' actually results in a merge conflict (e.g., the files you've changed locally were also modified in the upstream). The latter uses an explicit merge and also fetches all branches (including any new branches that were created since you cloned your repository and/or added 'upstream' as a remote). You can list all branches with:

 

$ git branch -a

 

If you don't see a branch in 'remotes/upstream' that you know is in the official repository, run the "git fetch upstream" and "git merge upstream/<missingBranch>" form.

 

Any local changes you have will be merged, and any local commits already in the upstream will be handled as a fast-forward merge (leaving your branch at the same commit as the "upstream/master").

 

Now that your local Git repository has the latest, go ahead and push all the new commits to your fork: 

Code Block
$ git push 

...

<you> master

...

This is an optional step. The "master" branch on your fork is not really used at all, but you can keep it up-to-date with the upstream repository if you want.

 

Make Changes

All changes should be made on topic branches, typically named according to the JIRA issueJIRA issue. (We recommend Recommended naming them convention "modefcrepo-xxxx".) There 's is nothing special about a "topic" branch -- it 's is just a normal Git branch that you create and use for a specific topic (i.e., JIRA issueJIRA issue). 

NOTE:  We will not accept pullPull-requests that use the 'master' branch will not be accepted, even in your fork repository. There are too many things that can go wrong. Firstly, doing so will make it difficult to work on more than one (independent) set of changes at a time; working on 'master' will make your second set of changes dependent upon the first set of changes. Secondly, GitHub pull-requests are tied to branches, so GitHub will want to include all your commits into the same pull-request. Thirdly (and perhaps most importantly), if your commits are not approved, your 'master' branch history will have commits that don't actually appear in the official 'master' branch, and this could be problematic in the future. The 'master' branch in your fork should really be just the local branch that represents the official repository's 'master' branch - use it to pull changes from upstream origin and merge/rebase onto your topic branches. 

To create a topic branch, start on a branch you want to base from (which is often 'master'). The following command creates a new branch named "modefcrepo-1234" (based off of 'master') and then checks out that branch: 

Code Block
$ git checkout -b 

...

fcrepo-1234 master

 

Your working directly reflects Work directly in the new "modefcrepo-1234" branch, and this . This is where you make your changes and run your new/modified unit tests. When you 're are happy, stage your changes with: 

Code Block
$ git add .

 

and do Do a complete integration build to make sure your new tests pass and that your changes didn't did not cause a regression: 

Code Block
$ mvn clean install

...

 

or, if you want to build the kits and run the integration tests, add the "integration" profile:

 

$ mvn clean install -Pintegration

...

NOTE: We didn't include the "-s settings.xml" argument on this or any other Maven commands shown on this page. We've assumed that you've modified your Maven settings. If you didn't, you will probably need to add this argument to all your Maven commands. If you get an error stating that some artifacts cannot be found, this is the reason.

 

If you need to make more changes, be sure to stage them and re-build.

 

Committing

...

Once everything builds, you can then commit your changes to this branch. There are various ways to commit, but this form will commit those changes you've staged and launches the editor where you can type out your commit message: 

Code Block
$ git commit

 

Be sure to use an appropriate comment. The first line should list issue numbers and a summary sentence; additional paragraphs describe the commit in more detail. (See ModeShape Development Guidelines.) offer a brief description of the change (less than 50 characters), followed by an empty line, followed by a more detailed description on one or more lines (each line not to exceed 72 characters), followed by an empty line, followed by "Resolves: <ticket URL>"

No Format
Address invisible resources during transactions

- Disable Last-Modified and Etag headers during transactions

Resolves: https://jira.duraspace.org/browse/FCREPO-1234

If you think it makes sense to commit multiple times on your topic branch, then feel free to do so. Having multiple commits on a topic branch is perfectly fine for large changes. However, if your topic branch only contains a small number of changes (e.g., fixing a bug in one class and then adding or changing a test case), then we do prefer it is preferred that they all be made in a single commit. You can create multiple commits and then squash them before pushing to your fork, but it is often easier to create the first commit as usual but then to amend that commit with subsequent changes:

 

$ git commit --amend

 

This will modify the previous commit to include the staged changes. Obviously, you should only amend your own commits on your topic branch - never amend a commit that on an official branch.

 

Rebasing

 

 

Note: After a pull-request has been submitted (see below), subsequent commits (based on response to code review comments) should be pushed to the same development branch so that they will automatically be added to the pull-request. Do not squash or amend subsequent commits into your original pull-request commits because it makes finding the deltas much more difficult for the code reviewer.

Rebasing

If you have If you've been working on this branch for a while, we other changes may have been merged other changes (from other pull-requests) into the upstream origin repository. Often times this is okay, as we can deal with overlaps like this. However, sometimes your local change will be affected by recent merges. It 's is best to make sure that you update your local clone before you create your pull-request. 

To do this, switch to the "master" branch, have Git obtain all recent commits, and then update your branch: 

Code Block
$ git

...

 checkout master          # switches to the 'master' branch

...


$ git

...

                               # 'upstream/master' onto your 'master' branch

$ git checkout mode-1234       # switches to your topic branch

$ git rebase master            # reapplies your changes on top of the latest

...

 pull origin master       # fetches all 'origin' changes and merges
                               # 'origin/master' onto your 'master' branch
$ git checkout fcrepo-1234     # switches to your topic branch
$ git rebase master            # reapplies your changes on top of the latest
                               # in master (i.e., the latest from master

...

 will
                               # be the new base for your changes)

                               # be the new base for your changes)

 

At this point, your "modefcrepo-1234" branch has been updated (rebased), and you can proceed.

 

NOTE: Do not ever merge these topic branches onto other official branches, even on your fork repository. That's our job. If you do that, your "master" branch (or any other official branch) will no longer reflect the official repository.

 

 

Push Changes

After you 've have committed changes locally (and pulled from upstream), you can commit your changes to your fork repository and generate a pull-request. Pushing the changes is easy: 

Code Block
$ git push 

...

<you> 

...

fcrepo-1234

...

This will push the commits on 'modefcrepo-1234' up to the 'origin' repository (which is your fork on GitHub). 

Create Pull-Request

After pushing your changes into your GitHub fork, you 've have published your changes but haven't have not really told the ModeShape Fedora community about them. To do this, generate a pull-request on GitHub; if you're . If your commits are on a branch other than 'master', be sure to update the commit range (changing 'master' to the correct branch name). Then record this on the JIRA issue "Workflow -> Link Pull Request" actionJIRA ticket, and use the URL to the pull-request and include a good comment that describes your changes.   Finish the JIRA ticket;  the ticket will then be ready to deliver, and the integration managers will be alerted that you have a pull request outstanding.

NOTE: If you use good commit descripitons descriptions and fill out a good pull-request description, then you can just paste the same description as the JIRA comment JIRA comment (without the summary line).

 

 

MeanwhileAfter the ticket is put "In Review", one of ModeShapeFedora's integration managers will be notified of your new pull-request. The role of an integration manager is to review the incoming pull-requests and decide whether and they should be accepted and on which branch(es) they should be merged. As such, only a few people have this responsibility.

 

An integration manager will review your request within a few days, and often much faster. They 'll will comment on your pull-request via the discussion or line nodesnotes, or in the JIRA ticket. If they like what they see, they 'll will merge your proposed changes into the correct branch(es), then "Close" your JIRA ticket. However, they may like to see additional changes, in which case they 'll will describe in the pull-request discussion area (or in line notes, or JIRA ticket) what they 'd would like you to change, and "Reject" the ticket, to indicate to the ticket owner that the ball is back in their court. If you disagree, just use the discussion area. Otherwise, go back to your local topic branch for this issue, make the requested changes, commit them locally, and push them to same branch in your fork repository (using the same commands as before). As long as you 're are on the same branch (not simply named the same, but actually the same branch), GitHub will automatically update the pull-request with your additional commit(s) and notify the integration managers again. Once they're acceptableFinish the JIRA ticket again. Once the changes are accepted, the integration managers will merge your commits into the upstream repository.

 

The aforementioned process adds your new commits to the pull-request. But sometimes, the integration managers will request just a few smaller changes, and making a separate commit for those small changes is less desirable. Instead, in this case we suggest that you make the changes and then amend your previous commit. This helps keep related changes in fewer commits, and makes it easier to apply the changes to other branches. Yes, amended commits actually do change history, so be sure to do this only with commits that appear only on a topic branch. We think it is perfectly acceptable (and sometimes preferable) to amend/change the commits on a pull request before it is merged onto an official branch (before this, a PR is really "proposed code"). The procedure is pretty straightforward. On your local branch (e.g., "mode-1234") that you used to push to your fork (e.g., "origin") and create the PR, make any additional changes to the code and then:

 

$ git commit --amend .

$ git push -f origin mode-1234

 

GitHub will automatically update the pull-request, where it can be reviewed once again.

 

Cleanup

NOTE: After your initial commit, please do not perform "git push --force" on your branch. Doing so requires a complete re-review of the entire pull-request since it is not clear what all changes have been forced. After the code review is complete and ready to be merged into the master branch, you may indicate if you want certain commits to be squashed or not. Typically, if all of the commits are simply iterations on a single unit of work, your commits will be squashed by the integration manager before being merged into master.

Cleanup

There is There's actually nothing else you need to do. However, you may want to periodically clean up the topic branches that are no longer needed. (Note that if you want to make additional changes on a topic branch and have them go into the original pull-request, don't do not delete the topic branch in your local repository or your fork repository on GitHub.) 

This command will delete a local topic branch: 

Code Block
$ git branch -D 

...

fcrepo-1234

 

while this This command deletes the remote branch in your fork repository on GitHub: 

Code Block
$ git push 

...

<you> :

...

fcrepo-1234

...

At first blush, the syntax of this second command is a little strange. It 's is actually a form of the "git push <remote> <localBranch>:<remoteBranch>" command. If you don't do not specify the local branch, this basically means push nothing onto the remote branch, and Git removes the remote branch.

The reviewer should:

...

Configure for Performing Code Reviews

Since pull-requests are used when offering patches for code review, if you are performing a code review, this is one way that you can configuration Git to simplify the process.

  1. At the top-level of the pertinent project directory, change your ".git/config" file as follows (notice addition of line:5)

    Code Block
    titleExample from the "fcrepo4" project
    linenumberstrue
    ...
    [remote "origin"]
            url = https://github.com/fcrepo4/fcrepo4.git
            fetch = +refs/heads/*:refs/remotes/origin/*
            fetch = +refs/pull/*/head:refs/remotes/origin/pull/*
    ...


  2. Refresh your local cache

    No Format
    git checkout master
    git pull


  3. Checkout the pull-request branch for review

    No Format
    git checkout --track origin pull/xxx


  4. Enjoy the review

 

...