Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sanitize_name methos doesn't cover all required cases. #34

Closed
stoune opened this issue Jul 4, 2014 · 2 comments
Closed

sanitize_name methos doesn't cover all required cases. #34

stoune opened this issue Jul 4, 2014 · 2 comments

Comments

@stoune
Copy link

stoune commented Jul 4, 2014

Sanitize name is failing if branch name has less than two symbols.
Also it filtering regexp doen't cover cases if branch name has ' = and some other symbols.

My version of this method looks like:

def sanitize_name(name,what="branch"):
        """Sanitize input roughly according to git-check-ref-format(1)"""

        def dot(name):
            if len(name) == 0:
              return name
            if name[0] == '.' and len(name) == 1:
              return '_'
            if name[0] == '.':    
              return '_'+name[1:]
            return name

        n=name
        p=re.compile('([[ ~^:?\\\\*\)\(\=\,\'#]|\.\.)')
        n=n.strip()
        n=p.sub('_', n)
        if n[-1] in ('/', '.'): n=n[:-1]+'_'
        n='/'.join(map(dot,n.split('/')))
        p=re.compile('_+')        
        n=p.sub('_', n)  
        if n!=name:
            sys.stderr.write('Warning: sanitized %s [%s] to [%s]\n' % (what,name,n))
        return n
@frej
Copy link
Owner

frej commented Jul 4, 2014

Sanitize name is failing if branch name has less than two symbols.
Also it converts it filtering regexp doen't cover cases if branch name
has ' = and some other symbols.

My version of this method looks like:
def sanitize_name(name,what="branch"):

As far as I can see, you have created three new issues for the same
problem. Please do not do that, just add further comments on the initial
report. I have closed issues 32 and 33 and kept this one as it provides
both an analysis and a proposed solution to the problem.

Could you provide your proposed change as a pull-request? It is much
easier to review that way.

@frej
Copy link
Owner

frej commented Aug 16, 2015

With the changes in 3c27c69 it should be possible to rename troublesome branch names, which makes this fix moot.

@frej frej closed this as completed Aug 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants