to get the file location, and then os.chdir(this_location) to
issue "git log" to detect if the file is in a git repo or not,
this is not so difficult, but then the following error occurs:
peter@cow:~$ ./gitbro/engine.py test-repo/out
11111111-basename:
out
22222222sss-abs:
/home/peter/test-repo/out
333333333-file_dir:
/home/peter/test-repo
/home/peter/test-repo
OK, we are in a repo, Let's get to work...
make dir...
fatal: ambiguous argument 'test-repo/out': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions
peter@cow:~$
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Not so urgent
OK, the bug report is sent to my gmail box, I wonder if everybody of gitbro-develop list can see the report
Billie, if you see this, plz also add a comment here
When I am trying to deal with this, I found I can use,
os.path.basename()
os.path.dirname()
os.path.abspatch()
to get the file location, and then os.chdir(this_location) to
issue "git log" to detect if the file is in a git repo or not,
this is not so difficult, but then the following error occurs:
peter@cow:~$ ./gitbro/engine.py test-repo/out
11111111-basename:
out
22222222sss-abs:
/home/peter/test-repo/out
333333333-file_dir:
/home/peter/test-repo
/home/peter/test-repo
OK, we are in a repo, Let's get to work...
make dir...
fatal: ambiguous argument 'test-repo/out': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions
peter@cow:~$
<example>
file_name = sys.argv[1] # this is the file we are working on
#FIXME, the following code has hole.
#what if $gitbro my-git-repo/file
basename = os.path.basename(file_name)
print "11111111-basename:"
print basename
abspath = os.path.abspath(basename)
print "22222222-abs:"
print abspath
file_dir = os.path.dirname(abspath)
print "333333333-file_dir:"
print file_dir
</example>
file_name = sys.argv[1] # this is the file we are working on
#FIXME, the following code has hole.
#what if $gitbro my-git-repo/file
basename = os.path.basename(file_name)
print "11111111-basename:"
print basename
abspath = os.path.abspath(file_name)
print "22222222sss-abs:"
print abspath
file_dir = os.path.dirname(abspath)
print "333333333-file_dir:"
print file_dir
os.chdir(file_dir)
print os.getcwd()
### check if in a git repo --begin
cmd="git log>/dev/null"
SO now a possible solution is let it be this way in engine.py, and handle this issue when we wrap engine in to a bash script. it will be easier.