Changes between Initial Version and Version 1 of MergerTips


Ignore:
Timestamp:
Jul 25, 2013, 7:31:39 AM (11 years ago)
Author:
Tim Graham
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • MergerTips

    v1 v1  
     1This page is an unofficial list of tips that may be useful for committers and other contributors to Django.
     2
     3== Automating Backports ==
     4
     5Backporting can be tedious. The following script makes it a bit easier by performing the `git cherry-pick` and modifying the commit message by prepending the branch name and appending "Backport of XXXXXXXX from master.".
     6
     7Put the contents below in `django-src/backport.sh`. Add `backport.sh` to `django-src/.git/info/exclude` to prevent the file from appearing in `git status`.
     8
     9After committing a change to master. Switch to the branch you wish to backport to and execute `./backport <hash of commit to backport>`. You can double check the commit message looks ok, then `git push`.
     10{{{
     11#!/bin/bash
     12BRANCH_NAME=`git branch | sed -n '/\* stable\//s///p'`
     13echo $BRANCH_NAME
     14
     15git reset --hard
     16
     17REV=$1
     18: ${ORIGBRANCH=master}
     19
     20TMPFILE=tmplog.tmp
     21
     22# Cherry-pick the other commit
     23#ORIGID=`git find-rev r${REV} ${ORIGBRANCH}`
     24#if [ -z "${ORIGID}" ] ; then
     25#    echo "Revision ${REV} not found in branch ${ORIGBRANCH}"
     26#    exit 1
     27#fi
     28git cherry-pick ${REV}
     29
     30# Create new log message by modifying the old one
     31git log --pretty=format:"[${BRANCH_NAME}] %s%n%n%b%nBackport of ${REV:0:10} from master" HEAD^..HEAD \
     32    | grep -v '^BP$' > ${TMPFILE}
     33
     34# Commit new log message
     35git commit --amend -F ${TMPFILE}
     36
     37# Clean up temporary files
     38rm -f ${TMPFILE}
     39}}}
     40
     41== Deleting empty directories and pyc files ==
     42
     43When switching branches, it's useful to delete directories that don't exist on the branch you're switching to, as well as pyc files so that state from one branch doesn't persist on the new one. Put the following contents in `django-src/.git/hooks/post-checkout` and ensure the file is executable (`chmod +x django-src/.git/hooks/post-checkout`).
     44
     45{{{
     46#! /bin/sh
     47
     48# Start from the repository root.
     49cd ./$(git rev-parse --show-cdup)
     50
     51# Delete .pyc files and empty directories.
     52find . -name "*.pyc" -delete
     53find . -type d -empty -delete
     54}}}
     55
     56== Running tests  ==
     57
     58Use the [https://github.com/jphalip/djangocore-box djangocore-box] VM to easily run the Django test suite using different Python versions and different database backends.
Back to Top