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

Fixed --convert-to-git-lfs command #158

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

AntonOvseenko
Copy link

  1. File .gitattributes created only in the root folder. Previously it created in all folders with lfs files.
  2. Generating .gitattributes file. All file extensions written in a new line.
    Before:
    *.{zip,mp4} filter=lfs diff=lfs merge=lfs -text
    After:
    *.zip filter=lfs diff=lfs merge=lfs -text
    *.mp4 filter=lfs diff=-lfs merge=lfs -text

root added 2 commits June 22, 2016 19:31
…d only in the root folder. Previously it created in all folders with lfs files. 2) Generating .gitattributes file. All file extensions written in a new line. Before: '*.{zip,mp4} filter=lfs diff=lfs merge=lfs -text.' After: '*.zip filter=lfs diff=lfs merge=lfs -text NEWLINE *.mp4 filter=lfs diff=-lfs merge=lfs -text'
… of the file .gitattributes in all directories with lfs files
@dakotahawkins
Copy link

I think this will work for the example, but not for other valid patterns.

E.g., I have some things specified with extension wildcards, and other things specified explicitly, so I'm trying to run it like:

--convert-to-git-lfs '{*.lib,*.blah,Exactly/this/file,Special/files/under/here/**/*.special}'

Obviously I don't want it to remove all the occurrences of '*.' and then add one to the front of everything.

@dakotahawkins
Copy link

dakotahawkins commented Jun 30, 2016

This may work better (haven't tested) at least for my particular case:

val globRegexMatcher = """([^{]*)\{?([^}]*)\}?(.*)""".r  
val globRegexMatcher(prefix, group, postfix) = lfsGlobExpression

val gitAttributes = group.split(",").map(prefix.concat(_).concat(postfix).concat(" filter=lfs diff=lfs merge=lfs -text"))

Anything before a '{' is the prefix, anything after a '}' is the postfix, and everything in between is assumed to be a comma-separated list.

I think if it's not using this syntax it should just spit out what you put in, but that might not work since in that case the whole string should be in prefix. This should be close though.

@AntonOvseenko
Copy link
Author

AntonOvseenko commented Jul 1, 2016

@dakotahawkins Thank you! Your fix really works. But there is a problem. Correctly handled only this particular case: '{*.lib,*.blah,filename.extension}'. I could not find the path to the file in the commit tree. I only have the file name.

@dakotahawkins
Copy link

Were you able to see what it does if you call it without the brace syntax? Like:

--convert-to-git-lfs '*.lib'

There may need to be a check that if group is empty (or if it doesn't contain commas, what does split do?) you just add one thing to gitAttributes that's prefix.concat(group).concat(postfix) or something like that.

@AntonOvseenko
Copy link
Author

Yes, I test it.I checked --convert-to-git-lfs: '*.lib', '*.{lib,png}', '{*.lib,*.png}', '{*.lib,*.png,filename.extension}'. All cases worked correctly.

@bicschneider
Copy link

is this fixed or abandonned ?

@AntonOvseenko
Copy link
Author

Good question ) Need to check, 4 years have passed and I have not used this tool anymore

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

Successfully merging this pull request may close these issues.

4 participants