Skip to content

Commit 1631fe2

Browse files
committed
Prepare publication on PyPI
1 parent db33343 commit 1631fe2

File tree

6 files changed

+120
-63
lines changed

6 files changed

+120
-63
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
(The MIT License)
2+
3+
Copyright (c) 2014 Fabien Meghazi
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the 'Software'), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ Of course you do ! Why would you be there ?
99
Installation
1010
------------
1111

12-
Just type this in your terminal:
13-
14-
sudo wget https://raw.githubusercontent.com/amigrave/git-qdiff/master/git-qdiff -P /usr/local/bin
15-
sudo chmod +x /usr/local/bin/git-qdiff
12+
pip install git-qdiff
1613

1714
Dependencies
1815
------------
@@ -29,20 +26,24 @@ Once installed, you should be able to use this command from any git repository:
2926

3027
git qdiff
3128

29+
And this should launch your favorite difftool:
30+
31+
[![screenshot](https://github.com/amigrave/git-qdiff/raw/master/screenshot.png)]
32+
3233
Of course you can use the same notations as you would with `git diff`:
3334

3435
```bash
3536
# Show both staged and unstaged changes
36-
git qdiff HEAD
37+
$ git qdiff HEAD
3738

3839
# Using tilde and carrets
39-
git qdiff HEAD~2..HEAD~3
40+
$ git qdiff HEAD~2..HEAD~3
4041

4142
# Between commits
42-
git qdiff 53c43de..7c70faf
43+
$ git qdiff 53c43de..7c70faf
4344

4445
# Between branches
45-
git qdiff my_feature..origin/master
46+
$ git qdiff my_feature..origin/master
4647

4748
# ...
4849
```
@@ -53,3 +54,8 @@ Known problem
5354
- `Refresh` button won't work
5455

5556
Before reporting an issue, please check that your `bzr qdiff` tool works well.
57+
58+
License
59+
-------
60+
61+
This software is licensed under the MIT license

git-qdiff

Lines changed: 4 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,8 @@
11
#!/usr/bin/env python
2-
import os
3-
from os.path import join as opj
4-
import subprocess
5-
import sys
6-
7-
class UnmetDependency(OSError):
8-
pass
9-
10-
def qdiff(left, right):
11-
left, right = opj(left, ''), opj(right, '')
12-
os.chdir(left)
13-
subprocess.check_call(['bzr', 'init', '-q'])
14-
subprocess.check_call(['bzr', 'add', '-q'])
15-
subprocess.check_call(['bzr', 'commit', '-qmm'])
16-
subprocess.check_call(['rsync', '-qavLt', '--delete', '--exclude=/.bzr', right, left])
17-
subprocess.check_call(['bzr', 'add', '-q'])
18-
subprocess.check_call(['bzr', 'qdiff', '-q'])
19-
20-
def check_dependencies():
21-
try:
22-
gitv = subprocess.check_output(['git', '--version']).split()[-1]
23-
except subprocess.CalledProcessError:
24-
raise UnmetDependency("Could not find `git` program")
2+
# -*- coding: utf-8 -*-
253

26-
ver = map(int, gitv.split('.')[0:3])
27-
if cmp(ver, [1, 7, 11]) < 0:
28-
raise UnmetDependency("Need at least `git` version 1.7.11+")
29-
30-
try:
31-
bzrv = subprocess.check_output(['bzr', 'version']).splitlines()[0].split()[-1]
32-
except subprocess.CalledProcessError:
33-
raise UnmetDependency("Could not find `bzr` program")
34-
35-
try:
36-
subprocess.check_output(['bzr', 'qdiff', '--help'])
37-
except subprocess.CalledProcessError:
38-
raise UnmetDependency("Could not find `bzr qdiff` plugin")
39-
40-
return gitv and bzrv # TODO: check minimum requirements
4+
import sys
5+
import git_qdiff
416

42-
if __name__ == '__main__':
43-
try:
44-
check_dependencies()
45-
except Exception, e:
46-
sys.exit(e.message)
47-
if len(sys.argv) == 3:
48-
left, right = sys.argv[1:3]
49-
if os.path.isdir(left) and os.path.isdir(right):
50-
qdiff(left, right)
51-
sys.exit(0)
7+
sys.exit(git_qdiff.main())
528

53-
# TODO: ensure infinite subcalls is not possible
54-
cmd = ['git', 'difftool', '-d', '-x'] + sys.argv
55-
# print("Launching '%s'" % ' '.join(cmd))
56-
try:
57-
subprocess.check_call(cmd)
58-
except subprocess.CalledProcessError, e:
59-
sys.exit("git failed with returncode %d" % e.returncode)

git_qdiff.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
import os
4+
from os.path import join as opj
5+
import subprocess
6+
import sys
7+
8+
class UnmetDependency(OSError):
9+
pass
10+
11+
def qdiff(left, right):
12+
left, right = opj(left, ''), opj(right, '')
13+
os.chdir(left)
14+
subprocess.check_call(['bzr', 'init', '-q'])
15+
subprocess.check_call(['bzr', 'add', '-q'])
16+
subprocess.check_call(['bzr', 'commit', '-qmm'])
17+
subprocess.check_call(['rsync', '-qavLt', '--delete', '--exclude=/.bzr', right, left])
18+
subprocess.check_call(['bzr', 'add', '-q'])
19+
subprocess.check_call(['bzr', 'qdiff', '-q'])
20+
21+
def check_dependencies():
22+
try:
23+
gitv = subprocess.check_output(['git', '--version']).split()[-1]
24+
except subprocess.CalledProcessError:
25+
raise UnmetDependency("Could not find `git` program")
26+
27+
ver = map(int, gitv.split('.')[0:3])
28+
if cmp(ver, [1, 7, 11]) < 0:
29+
raise UnmetDependency("Need at least `git` version 1.7.11+")
30+
31+
try:
32+
bzrv = subprocess.check_output(['bzr', 'version']).splitlines()[0].split()[-1]
33+
except subprocess.CalledProcessError:
34+
raise UnmetDependency("Could not find `bzr` program")
35+
36+
try:
37+
subprocess.check_output(['bzr', 'qdiff', '--help'])
38+
except subprocess.CalledProcessError:
39+
raise UnmetDependency("Could not find `bzr qdiff` plugin")
40+
41+
return gitv and bzrv # TODO: check minimum requirements
42+
43+
def main():
44+
try:
45+
check_dependencies()
46+
except Exception, e:
47+
sys.exit(e.message)
48+
if len(sys.argv) == 3:
49+
left, right = sys.argv[1:3]
50+
if os.path.isdir(left) and os.path.isdir(right):
51+
qdiff(left, right)
52+
sys.exit(0)
53+
54+
# TODO: ensure infinite subcalls is not possible
55+
cmd = ['git', 'difftool', '-d', '-x'] + sys.argv
56+
# print("Launching '%s'" % ' '.join(cmd))
57+
try:
58+
subprocess.check_call(cmd)
59+
except subprocess.CalledProcessError, e:
60+
sys.exit("git failed with returncode %d" % e.returncode)

screenshot.png

128 KB
Loading

setup.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
from setuptools import setup
4+
5+
with open('README.md') as f:
6+
long_description = f.read()
7+
8+
setup(
9+
name='git-qdiff',
10+
version='0.1',
11+
author='Fabien Meghazi',
12+
author_email='[email protected]',
13+
license='MIT',
14+
description="Bzr tool's qdiff for git",
15+
long_description=long_description,
16+
keywords='git qdiff bzr diff',
17+
url = 'https://github.com/amigrave/git-qdiff',
18+
py_modules = ['git_qdiff'],
19+
scripts = ['git-qdiff'],
20+
)
21+

0 commit comments

Comments
 (0)