Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8496831

Browse files
committed
improved git.cmd documentation
1 parentbca0cb7 commit8496831

File tree

1 file changed

+43
-8
lines changed

1 file changed

+43
-8
lines changed

‎lib/git/cmd.py

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,47 @@
2222

2323
classGit(object):
2424
"""
25-
The Git class manages communication with the Git binary
25+
The Git class manages communication with the Git binary.
26+
27+
It provides a convenient interface to calling the Git binary, such as in::
28+
29+
g = Git( git_dir )
30+
g.init() # calls 'git init' program
31+
rval = g.ls_files()# calls 'git ls-files' program
32+
33+
``Debugging``
34+
Set the GIT_PYTHON_TRACE environment variable print each invocation
35+
of the command to stdout.
36+
Set its value to 'full' to see details about the returned values.
2637
"""
2738
def__init__(self,git_dir):
39+
"""
40+
Initialize this instance with:
41+
42+
``git_dir``
43+
Git directory we should work in. If None, we always work in the current
44+
directory as returned by os.getcwd()
45+
"""
2846
super(Git,self).__init__()
2947
self.git_dir=git_dir
3048

3149
def__getattr__(self,name):
50+
"""
51+
A convenience method as it allows to call the command as if it was
52+
an object.
53+
Returns
54+
Callable object that will execute call _call_process with your arguments.
55+
"""
3256
ifname[:1]=='_':
3357
raiseAttributeError(name)
3458
returnlambda*args,**kwargs:self._call_process(name,*args,**kwargs)
3559

3660
@property
3761
defget_dir(self):
62+
"""
63+
Returns
64+
Git directory we are working on
65+
"""
3866
returnself.git_dir
3967

4068
defexecute(self,command,
@@ -49,7 +77,9 @@ def execute(self, command,
4977
the returned information (stdout)
5078
5179
``command``
52-
The command argument list to execute
80+
The command argument list to execute.
81+
It should be a string, or a sequence of program arguments. The
82+
program to execute is the first item in the args sequence or string.
5383
5484
``istream``
5585
Standard input filehandle passed to subprocess.Popen.
@@ -68,11 +98,15 @@ def execute(self, command,
6898
``with_raw_output``
6999
Whether to avoid stripping off trailing whitespace.
70100
71-
Returns
72-
str(output) # extended_output = False (Default)
73-
tuple(int(status), str(output)) # extended_output = True
101+
Returns::
102+
103+
str(output) # extended_output = False (Default)
104+
tuple(int(status), str(stdout), str(stderr)) # extended_output = True
105+
106+
NOTE
107+
If you add additional keyword arguments to the signature of this method,
108+
you must update the execute_kwargs tuple housed in this module.
74109
"""
75-
76110
ifGIT_PYTHON_TRACEandnotGIT_PYTHON_TRACE=='full':
77111
print' '.join(command)
78112

@@ -146,7 +180,8 @@ def _call_process(self, method, *args, **kwargs):
146180
the result as a String
147181
148182
``method``
149-
is the command
183+
is the command. Contained "_" characters will be converted to dashes,
184+
such as in 'ls_files' to call 'ls-files'.
150185
151186
``args``
152187
is the list of arguments
@@ -156,7 +191,7 @@ def _call_process(self, method, *args, **kwargs):
156191
This function accepts the same optional keyword arguments
157192
as execute().
158193
159-
Examples
194+
Examples::
160195
git.rev_list('master', max_count=10, header=True)
161196
162197
Returns

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp