pip install future
# http://python-future.org/futurize_cheatsheet.html- Why fork (not clone): https://stackoverflow.com/questions/6286571/are-git-forks-actually-git-clones
- If you do not have write access to the repo then you must fork (not clone) the repo (upstream) into a repo (origin) in your own GitHub account. You then make changes and commits to a repo (local) on your computer and push those changes from local to origin. Then you can create a pull request to suggest that changes move from origin to upstream.
- Syncing with upstream: https://docs.python.org/devguide/gitbootcamp.html#syncing-with-upstream
- Using the GitHub web ui, visit the repo to be processed and click "fork" in the upper right (not clone).
- $ git clone
https://github.com/<your GitHub username>/<repo name>
- $ cd
<repo name>
- $ git remote add upstream
https://github.com/<repo username>/<repo name>
- $ git checkout -b modernize-python2-code
- $ python2 -m flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics
- $ futurize --stage1 -x libfuturize.fixes.fix_absolute_import -w .
- Or $ futurize -f libfuturize.fixes.fix_print_with_import -w .
- $ python3 -m flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics
- $ git commit -am "Modernize Python 2 code to get ready for Python 3"
- $ git push --force origin modernize-python2-code
- $ open
https://github.com/<repo username>/<repo name>
Refreshes GitHub web ui and you should have a Pull Request to submit back to upstream.
There are two problems with automating this process. Neither git CLI nor github3.py support:
- creating a fork
- creating a pull request (See: https://github.com/cclauss/git-push-inside-travis)
New proposal:
- Using the GitHub web ui, the user visits the repo to be processed and clicks "fork" in the upper right (not clone).
- User runs
itinerant_futurizer.py
locally and when asked provide their GitHub password. - At the end of processing, a web browser is opened to the
futurize-stage-1
branch of the origin repo. - User can create a pull request to suggest that changes move from origin to upstream.
Under this proposal, itinerant_futurizer.py
does:
- Ask user for their GitHub password
- Get the last repo created and ask user to verify this is the repo that they want to process
- Verify that branch futurize-stage-1 does not yet exist on origin. If it does then bail.
- If .travis.yml exists in that repo then rename it to was.travis.yml
- travis enable -r user/repo # https://github.com/travis-ci/travis.rb#enable
- Push our .travis.yml into repo to kick off futurize stage 1
- Remove our .travis.yml and restore was.travis.yml if present
- Open webbrowser to branch futurize-stage-1 on origin
Our .travis.yml does:
- git checkout -b futurize-stage-1
- pip install future
- futurize --stage1 --nofix=libfuturize.fixes.fix_absolute_import -w .
- git commit --all -m "Modernize Python 2 code to get ready for Python 3"
- git push --set-upstream origin futurize-stage-1
- rm .travis.yml
- mv was.travis.yml .travis.yml
ArduPilot/ardupilot#6954 (comment)
Zap trailing whitespace: sed -i 's/ +$//' **/*.py