swcarpentry / DEPRECATED-bc

DEPRECATED: This repository is now frozen - please see individual lesson repositories.
Other
299 stars 383 forks source link

Extract history of intermediate Git lesson #929

Closed bast closed 7 years ago

bast commented 9 years ago

this will happen in https://github.com/rbast/swc-intermediate-git/

bast commented 9 years ago

For my and future reference git/intermediate appeared in 5819712 and was renamed to intermediate/git in b8c7dc3.

bast commented 9 years ago

EDIT: the extraction following this script was discarded and a new extraction restarted (see below).

Extraction followed the git filter-branch strategy outlined in https://github.com/swcarpentry/bc/issues/877:

# adapted to intermediate/git based on https://github.com/swcarpentry/bc/issues/877

# adapt these:
GH_USER=rbast
LEVEL=intermediate
LESSON=git

git clone https://github.com/swcarpentry/bc
cd bc

# filter out the $LEVEL/$LESSON directory into a new branch
# '$LEVEL-$LESSON-history'
git checkout -b $LEVEL-$LESSON-history
git filter-branch --subdirectory-filter $LEVEL/$LESSON --prune-empty -f

# attach missed older history (from bc reorgs)
# https://github.com/wking/swc-modular-shell/issues/3
# (because lesson now in $LEVEL/$LESSON used to be in $LESSON/$LEVEL)

# goto the commit before the reorg
git checkout -b $LESSON-$LEVEL b8c7dc3^
# move $LESSON/$LEVEL to root and rewrite all commits accordingly
git filter-branch --subdirectory-filter $LESSON/$LEVEL --prune-empty -f

# now rebase to add this to the history
git checkout $LEVEL-$LESSON-history
ORPHAN_COPY_COMMIT=$(git rev-parse 'HEAD^{/Reorganizing material}')
git rebase -p --onto $LESSON-$LEVEL "${ORPHAN_COPY_COMMIT}"

# delete the temp branch
git branch -D $LESSON-$LEVEL

# we now have a branch called '$LEVEL-$LESSON-history' that contains the
# history of only the $LEVEL $LESSON lesson, with all of the files in the top
# level.

# now we create a new repo and pull into it from this branch:
mkdir swc-$LEVEL-$LESSON
cd swc-$LEVEL-$LESSON
git init
git remote add bc ../../bc
git checkout -b $LEVEL-$LESSON-history
git pull bc $LEVEL-$LESSON-history

However there were few empty merge commits and also unrelated-looking empty commits so the history was cleaned up using:

# history before cleanup:
#     17e8a2b Fix more level 3 headings
#     b3f9d5d Fixes #546 by using level-3 headings in all Markdown source files for subsections. We continue to use level-4 headings for objectives, key points, call
#     bc046c9 Fix links to glossary
#     859a864 fixed typeos
#     c7c7e66 refactored git relational lesson into intermediate material
#     c6ff7fd Merge pull request #243 from ahmadia/git-intermediate
#     cb474e7 Newline missing for one code markup
#     071e215 Fix code formatting
#     9118501 Fix code formatting
#     0734c9c Incorporate feedback from @wking
#     338ff0d 2nd draft of Conversational Git
#     5355f7e minor grammatical fixes, added BitBucket
#     6616508 fix line break typo
#     b3810c7 Added first part of Conversational Git section.
#     3b63821 Start of new Git Intermediate lessons
#     67d7359 Merge branch 'master' into new-python-beginner-lessons
#     50be3a1 Merge branch 'bc-namespaced' of git://tremily.us/swc-setup-installation-test into bc-setup
#     4c57544 Laying out new material
#     5bafe5a Merge branch 'nano-installer' into windows-installer
#     ae6a238 Merge Konrad Hinsen and Fernando Perez's installation-testing scripts

# remove root commit that seems unrelated and is empty
git filter-branch --parent-filter "sed 's/-p ae6a23894818f7dac65bd87bf98fb3c83146b626//'" -f HEAD

# remove root commit (previously second commit) that seems unrelated and is empty
git filter-branch --parent-filter "sed 's/-p 5bafe5a835f04fd1cf50dc1ecb629baa819beebf//'" -f HEAD

# use interactive rebase to prune out empty merge commits
# in there remove one of the empty merge commits and it will prune out all
# other empty commits
git rebase -i 4c5754486ea950a6f14d33192c8e54a2cfdc5a98

# verify
git log --oneline
# history after cleanup:
#     67897b3 Fix more level 3 headings
#     a2b1e92 Fixes #546 by using level-3 headings in all Markdown source files for subsections. We continue to use level-4 headings for objectives, key points, call
#     5bc6df7 Fix links to glossary
#     f9fe034 fixed typeos
#     16fef41 refactored git relational lesson into intermediate material
#     6db703a Newline missing for one code markup
#     561c080 Fix code formatting
#     d79e80f Fix code formatting
#     5892741 Incorporate feedback from @wking
#     10f86d4 2nd draft of Conversational Git
#     cd9c3bd minor grammatical fixes, added BitBucket
#     5993b71 fix line break typo
#     8f55858 Added first part of Conversational Git section.
#     486b962 Start of new Git Intermediate lessons
#     4c57544 Laying out new material
bast commented 9 years ago

History extraction was restarted using the following script. The motivation for this was to go further back in history to lessons/swc-git. The byproduct is cleaner extraction script and also cleaner history than in first attempt.

# adapted to intermediate/git based on https://github.com/swcarpentry/bc/issues/877
# history points:
#     lessons/swc-git started in cc37b0e
#     restructured to git/intermediate in 5819712
#     renamed to intermediate/git in b8c7dc3

git clone https://github.com/swcarpentry/bc
cd bc

# extract the 3 history parts into individual branches (part1, part2, part3)
git checkout -b part1 5819712^
git filter-branch --subdirectory-filter lessons/swc-git --prune-empty -f
git checkout -b part2 b8c7dc3^
git filter-branch --subdirectory-filter git/intermediate --prune-empty -f
git checkout -b part3 gh-pages
git filter-branch --subdirectory-filter intermediate/git --prune-empty -f

# now rebase part2 on top of part1
git checkout part2
git rebase part1
# then rebase part3 on top of part2
git checkout part3
git rebase part2

# we create a new branch from the tip of part3 just for clarity
git checkout -b intermediate-git-history
# at this point we have are on the branch intermediate-git-history
# which contains the history of this lesson only, with all
# the files in the top level

# now we create a new repo and pull the combined history into it
mkdir swc-intermediate-git
cd swc-intermediate-git
git init
git remote add bc ../../bc
git checkout -b intermediate-git-history
git pull bc intermediate-git-history

# now we push the branch to a separate repo on github
git remote add origin git@github.com:rbast/swc-intermediate-git.git
git push -u origin intermediate-git-history
bast commented 9 years ago

@wking can you please review this? The extracted history is in https://github.com/rbast/swc-intermediate-git. If this looks good, we can proceed transforming to new lesson template.

kynan commented 9 years ago

Why were there empty commits despite using --prune-empty?

bast commented 9 years ago

After some debugging and head scratching I found that this was due to the Git version. I originally ran the extraction script that I posted on Jan 14 on a Debian (derived) box with Git 1.7.10.4. This produced ugly history which I then tried to clean up (curing the symptoms but not the problem). Running the exact same script now with Git 1.9.1 works fine and does not generate empty commits. The script I posted on Feb 15 works fine also using the older Git version.

wking commented 9 years ago

On Sun, Feb 15, 2015 at 01:38:23PM -0800, Radovan Bast wrote:

now rebase part2 on top of part1

git checkout part2 git rebase part1

I'd rather use 'git rebase -p part1' here (and when grafting part3 onto part2) to preserve any merges that survived the initial filter-branch. Other than that, this looks good to me.

bast commented 9 years ago

Thanks Trevor, I will replay the extraction with -p and comment here as soon as it is done.

bast commented 9 years ago

With git rebase -p only one file (tutorial.md) survives the extraction in contrast to git rebase where the result is:

00-intro.md
01-conversational-git.md
02-relational-structure.md
README.md
index.md
tutorial.md

I am trying to figure out why that is.

bast commented 7 years ago

Reanimating this old issues (apologies for letting it rest so long) - I have looked further into it and rebase -p fails for me and basically throws away all commits after the new base (I admit I do not understand why). Fortunately however, both rebased branches do not contain any merge commits and therefore I believe we can go with the current recipe (without -p) and keep the presently extracted code?

wking commented 7 years ago

On Wed, Jul 27, 2016 at 04:55:29AM -0700, Radovan Bast wrote:

Reanimating this old issues (apologies for letting it rest so long)…

I think @rgaiacs has started 1 from scratch without much referernce to this stuff, so it's probably not worth pulling this out into it's own branch anymore.

bast commented 7 years ago

Thanks - should we then consider this issue as irrelevant/closed?

wking commented 7 years ago

On Wed, Jul 27, 2016 at 11:53:58AM -0700, Radovan Bast wrote:

Thanks - should we then consider this issue as irrelevant/closed?

Probably.

gvwilson commented 7 years ago

Done - thanks all.