Menu

#1 gitbro can not handle file name with parent dir

open
5
2010-01-26
2010-01-26
Peter Wang
No

peter@cow:~$ python engine.py test-repo/out
fatal: Not a git repository
sorry gitbro only handles files in git, so Bye!
peter@cow:~$

Discussion

  • Peter Wang

    Peter Wang - 2010-01-26

    Not so urgent

     
  • Peter Wang

    Peter Wang - 2010-01-26

    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

     
  • Peter Wang

    Peter Wang - 2010-01-26
    • labels: --> engine logic
    • assigned_to: nobody --> happypeter
     
  • Peter Wang

    Peter Wang - 2010-01-26
    • summary: gitbro can not hadle file name with parent dir --> gitbro can not handle file name with parent dir
     
  • Peter Wang

    Peter Wang - 2010-01-26

    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:~$

     
  • Peter Wang

    Peter Wang - 2010-01-26

    <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"

     
  • Peter Wang

    Peter Wang - 2010-01-26

    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.

     

Log in to post a comment.