forked from scrapy/scrapy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added script to split selectors with patches
- Loading branch information
Showing
9 changed files
with
2,505 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
#!/bin/bash | ||
|
||
# startover | ||
git checkout master # in future comment this so you can checkout your desired commit | ||
git branch -D selectors selector-code utils-code tests-code selectors-separation | ||
|
||
# split scrapy/selector dir to selector-code branch | ||
git checkout -b selector-code | ||
git filter-branch -f --prune-empty \ | ||
--subdirectory-filter scrapy/selector -- selector-code | ||
# mv files to selectors/ dir without new commit | ||
git filter-branch -f \ | ||
--index-filter ' | ||
git ls-files -s \ | ||
| sed "s-\t-&selectors/-" \ | ||
| GIT_INDEX_FILE=$GIT_INDEX_FILE.new git update-index --index-info \ | ||
&& mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' | ||
|
||
# now we need to split utils | ||
git checkout master | ||
|
||
# split scrapy/utils dir to utils-code branch | ||
git checkout -b utils-code | ||
git filter-branch -f --prune-empty \ | ||
--subdirectory-filter scrapy/utils -- utils-code | ||
# only keep required utils files | ||
git filter-branch -f \ | ||
--prune-empty \ | ||
--index-filter ' | ||
git ls-tree -z -r --name-only --full-tree $GIT_COMMIT \ | ||
| grep -z -v "^__init__.py$" \ | ||
| grep -z -v "^decorator.py$" \ | ||
| grep -z -v "^misc.py$" \ | ||
| grep -z -v "^python.py$" \ | ||
| xargs -0 -r git rm --cached -r | ||
' \ | ||
-- \ | ||
utils-code | ||
# mv files to selectors/utils/ dir without new commit | ||
git filter-branch -f \ | ||
--index-filter ' | ||
git ls-files -s \ | ||
| sed "s-\t-&selectors/utils/-" \ | ||
| GIT_INDEX_FILE=$GIT_INDEX_FILE.new git update-index --index-info \ | ||
&& mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' | ||
|
||
# now we need to split tests | ||
git checkout master | ||
|
||
# split tests dir to tests-code branch | ||
git checkout -b tests-code | ||
git filter-branch -f --prune-empty \ | ||
--subdirectory-filter tests -- tests-code | ||
# only keep required tests files | ||
git filter-branch -f \ | ||
--prune-empty \ | ||
--index-filter ' | ||
git ls-tree -z -r --name-only --full-tree $GIT_COMMIT \ | ||
| grep -z -v "^__init__.py$" \ | ||
| grep -z -v "^test_selector.py$" \ | ||
| grep -z -v "^test_selector_csstranslator.py$" \ | ||
| xargs -0 -r git rm --cached -r | ||
' \ | ||
-- \ | ||
tests-code | ||
# mv files to tests/ dir without new commit | ||
git filter-branch -f \ | ||
--index-filter ' | ||
git ls-files -s \ | ||
| sed "s-\t-&tests/-" \ | ||
| GIT_INDEX_FILE=$GIT_INDEX_FILE.new git update-index --index-info \ | ||
&& mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' | ||
|
||
# centralized branch for all selectors code | ||
git checkout --orphan selectors | ||
git rm -r -f . | ||
|
||
# merge and rebase separate branches | ||
git merge selector-code | ||
git rebase utils-code | ||
git rebase tests-code | ||
|
||
# release branches | ||
git branch -D selector-code utils-code tests-code | ||
|
||
# now we can apply selectors patches | ||
for f in $(ls patches/selectors/2015-03-18/); do | ||
git am < patches/selectors/2015-03-18/$f; | ||
done | ||
|
||
# now we can remove selectors from scrapy | ||
git checkout master | ||
git checkout -b selectors-separation | ||
# apply scrapy patches | ||
for f in $(ls patches/scrapy/2015-03-18/); do | ||
git am < patches/scrapy/2015-03-18/$f; | ||
done | ||
|
||
# references | ||
# http://git-scm.com/docs/git-filter-branch | ||
# http://git-scm.com/docs/git-ls-tree | ||
# examples | ||
# https://stackoverflow.com/questions/359424/detach-subdirectory-into-separate-git-repository | ||
# https://stackoverflow.com/questions/359424/detach-subdirectory-into-separate-git-repository | ||
# https://github.com/apenwarr/git-subtree/blob/master/git-subtree.txt | ||
# https://stackoverflow.com/questions/6403715/git-how-to-split-off-library-from-project-filter-branch-subtree?rq=1 | ||
# https://stackoverflow.com/questions/5998987/splitting-a-set-of-files-within-a-git-repo-into-their-own-repository-preserving | ||
# https://www.kernel.org/pub/software/scm/git/docs/git-filter-branch.html | ||
# http://stackoverflow.com/a/7396584 | ||
# https://stackoverflow.com/questions/8131135/git-how-to-diff-two-different-files-in-different-branches |
58 changes: 58 additions & 0 deletions
58
patches/scrapy/2015-03-18/0001-dev-and-prod-dependencies-of-selectors-library-tempo.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
From dc807a166588d54b8efe181b188f51b2322a7eb1 Mon Sep 17 00:00:00 2001 | ||
From: Umair Ashraf <umr.ashrf@gmail.com> | ||
Date: Wed, 18 Mar 2015 17:37:13 +0500 | ||
Subject: [PATCH 1/3] dev and prod dependencies of selectors library | ||
(temporary) | ||
|
||
--- | ||
requirements.txt | 1 + | ||
setup.py | 4 ++++ | ||
tox.ini | 2 ++ | ||
3 files changed, 7 insertions(+) | ||
|
||
diff --git a/requirements.txt b/requirements.txt | ||
index 005b8f4..309f1e6 100644 | ||
--- a/requirements.txt | ||
+++ b/requirements.txt | ||
@@ -5,3 +5,4 @@ cssselect>=0.9 | ||
w3lib>=1.8.0 | ||
queuelib | ||
six>=1.5.2 | ||
+git+https://github.com/umrashrf/selectors.git#egg=selectors | ||
diff --git a/setup.py b/setup.py | ||
index d463bcc..25f5717 100644 | ||
--- a/setup.py | ||
+++ b/setup.py | ||
@@ -44,5 +44,9 @@ setup( | ||
'pyOpenSSL', | ||
'cssselect>=0.9', | ||
'six>=1.5.2', | ||
+ 'selectors', | ||
+ ], | ||
+ dependency_links=[ | ||
+ 'git+https://github.com/umrashrf/selectors.git#egg=selectors' | ||
], | ||
) | ||
diff --git a/tox.ini b/tox.ini | ||
index 2dff749..e7b486a 100644 | ||
--- a/tox.ini | ||
+++ b/tox.ini | ||
@@ -30,6 +30,7 @@ deps = | ||
cssselect==0.9.1 | ||
zope.interface==3.6.1 | ||
-rtests/requirements.txt | ||
+ git+https://github.com/umrashrf/selectors.git#egg=selectors | ||
|
||
[testenv:trunk] | ||
basepython = python2.7 | ||
@@ -52,6 +53,7 @@ deps = | ||
# tests requirements | ||
pytest>=2.6.0 | ||
pytest-twisted | ||
+ git+https://github.com/umrashrf/selectors.git#egg=selectors | ||
|
||
[testenv:py34] | ||
basepython = python3.4 | ||
-- | ||
1.9.1 | ||
|
Oops, something went wrong.