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

Fix root directory regex #16

Closed
wants to merge 312 commits into from
Closed

Conversation

cenksoykan
Copy link
Contributor

I have not tested it out yet, but any directory path that starts with otf should be stay as root

Examples:

"otf/FiraCode-Medium.otf"
"../source-code-pro-#{version}/OTF/SourceCodePro-Regular.otf"
"OTF/SourceSerifPro-Regular.otf"
"NotoSans-Medium.ttf"

Fixes #8, and resolves #6

@cenksoykan
Copy link
Contributor Author

Now CooperHewitt, Chapbook, and TexGyrePagella fonts are probably broken.

@tani
Copy link
Member

tani commented Oct 3, 2019

Thank you for great contribution. I'm happy to see that you try to fix this issue.
I'm sorry that it seems that you misunderstood why the casks are broken.
Did you read my comment? #6 (comment)

I know some otf directories should stay as root. Shall I explain the description of this issue to you? The fonts are distributed with some formats such as zip and tar.gz. Especially, zip causes this issue sometimes because the original creator of fonts zipped fonts with various directory structures.

  1. zip with a directory

    foo.zip
    foo/otf/foo.otf
    foo/README.md
    foo/ttf/foo.ttf
    

    In this case we should remove the root directory.

  2. zip with several directories

    foo.zip
    otf/foo.otf
    README.md
    ttf/foo.ttf
    

    In this case, as you know, we should not remove the directories.

Unfortunately, It's difficult to know which case the zip file is before converting from casks to formulae.

We are welcome to fix this issue by you but we cannot merge your request without improvements of casks2formulae because we do not have enough time to follow the updates manually.

Regards.

@tani tani self-requested a review October 3, 2019 06:29
@tani tani added bug Something isn't working help wanted Extra attention is needed labels Oct 3, 2019
@cenksoykan
Copy link
Contributor Author

Thanks for the nice explanation 👋

I have already changed casks2formulae it is not a manual update

If structure is like first case it will go upper directory (any directory other than otf folder)
For second case it will stay where it is by looking this pattern "otf/ (otf folder is not likely to contain a subfolder therefore it should be a root) we can save some (4) typefaces otherwise all casks under otf folder are fails. Default pattern is anything between " and / like "foo/

My commit fails because it also changes directory if there is something like foo-otf/ folder (it supposed to be only otf), it doesn't know which scenario is happening for that reason some fonts are working others not so for those fuzzy casks not touching them is better

@tani
Copy link
Member

tani commented Oct 4, 2019

Okay, the regular expression becomes a complex notation if you try to make it run correctly for this case. I prefer to use if ... else ... clause instead of the regular expression for this situation.

@cenksoykan
Copy link
Contributor Author

I don't know much about ruby but I have a really terrible idea. Make a #{prefix} which is a shell %x( command ) looking for zipinfo for downloaded zip file in the .cache folder and if there is only one folder inside the zip except for dotfiles and __MACOSX then it can echo ../ else nothing. 😝

My last commit covers just a little bit better than before but it is not going to be a perfect solution ever.

@tani
Copy link
Member

tani commented Oct 5, 2019

Wow, you're cool. It's an interesting solution but, as you said, it is also a terrible idea.
Could you show me the result brew audit --strict <font formula >?
If it passes the tests, let's do this way!

@cenksoykan
Copy link
Contributor Author

Am I doing it right? This is the result:

font-fira-code:
  * C: 4: col 3: `url` (line 4) should be put before `version` (line 2)
  * C: 5: col 3: `desc` (line 5) should be put before `url` (line 4)
  * C: 6: col 3: `homepage` (line 6) should be put before `url` (line 4)
  * C: 14: col 3: `test do` should not be empty
  * Stable: version 2 is redundant with version scanned from URL
Error: 5 problems in 1 formula detected

All of them has similar output
It is exactly the same output with origin master

@tani
Copy link
Member

tani commented Oct 8, 2019

Sorry for the late reply. I'll check soon. Give me a day.

@tani
Copy link
Member

tani commented Oct 9, 2019

Issue #15 does block to merging this contribution.

@tani
Copy link
Member

tani commented Oct 23, 2019

@cenksoykan I'm sorry for late reply. I'm so happy to inform you that we can merge this request!
Could you tell me your status?

@cenksoykan
Copy link
Contributor Author

No problem at all, thanks for your attention from day zero 👏 this is awesome I am so glad you also fixed GitHub Actions quickly as possible 🎉 Sorry, I couldn't reply for a while but I will inform you soon

@cenksoykan
Copy link
Contributor Author

OK I have just checked upstream modifications and everything is same as we talked. What do you want to know?

In terms of clarity, if you merge this request those 6 fonts can be installed:

font-alef font-clear-sans font-fantasque-sans-mono font-fira-code font-source-serif-pro font-victor-mono

BUT unfortunately font-courier-prime-code (latest commit: Jun 15, 2019) and font-hack (latest commit: Oct 7, 2018) cannot be installed even though they are currently working. So bad! This is a rare situation, both have a directory named by font format but the problem is that it contains only one format which is unpredictable. 😞

Due to the zip issue you mentioned, some fonts cannot be fixed without a different approach and their status doesn't change:

font-baloo font-d2coding font-input font-inter font-libertinus font-muli font-overpass font-public-sans font-px437-pxplus font-vollkorn font-xits

Btw, have you ever considered cleaning formula directory? There are 274 fonts removed from homebrew-cask-fonts therefore some fonts will not be affected ever or some give 404 error

font-aegean font-aleo font-antinoou font-babelstone-han font-baron font-bebas-neue font-bf-tiny-hand font-blockzone font-bravura font-butler font-canter font-code2000 font-code2001 font-code font-colus font-cwtex-q font-dana-yad font-dangrek font-digohweli font-disclaimer font-dr-sugiyama font-dukor font-emblema-one font-expletus-sans font-free-hk-kai font-fugaz-one font-gandom font-genjyuugothic-l font-glober font-gveret-levin font-idealist-sans font-im-fell-double-pica font-im-fell-double-pica-sc font-im-fell-dw-pica font-im-fell-dw-pica-sc font-im-fell-english font-im-fell-english-sc font-im-fell-french-canon font-im-fell-french-canon-sc font-im-fell-great-primer font-im-fell-great-primer-sc font-inter-ui font-just-me-again-down-here font-kacstone font-kantumruy font-karla-tamil-inclined font-karla-tamil-upright font-kavoon font-kayases font-kdam-thmor font-keania-one font-keep-calm font-kelly-slab font-kenia font-khand font-kisiska font-knewave font-kopub font-koruri font-kotta-one font-koulen font-lalezar font-lateef font-league-script font-lily-script-one font-marta font-mfizz font-molengo font-monofett font-moulpali font-mr-de-haviland font-namdhinggo-sil font-new-athena-unicode font-nexa font-nexa-rust font-nika font-norwester font-noto-serif-georgian font-numans font-odor-mean-chey font-offside font-oldenburg font-oleo-script font-oleo-script-swash-caps font-oregano font-orienta font-original-surfer font-oskiblackfoot font-oskidakelh font-oskidenea font-oskideneb font-oskidenec font-oskidenes font-oskieast font-oskiwest font-over-the-rainbow font-ovo font-palemonas font-paprika font-parastoo font-parisienne font-passero-one font-pathway-gothic-one font-patrick-hand font-patrick-hand-sc font-paytone-one font-penuturesu font-peralta font-petrona font-phetsarath font-philosopher font-piedra font-pinyon-script font-pirata-one font-pitabek font-plaster font-playball font-play font-podkova font-poly font-pompiere font-pontano-sans font-port-lligat-sans font-port-lligat-slab font-preahvihear font-prime font-prince-valiant font-prosto-one font-puritan font-purple-purse font-qataban font-quando font-quantico font-quintessential font-quivira font-qwigley font-racing-sans-one font-radley font-rambla font-rammetto-one font-rancho font-rationale font-red-october font-redressed font-reenie-beanie font-revalia font-risque font-rochester font-rock-salt font-rokkitt font-romanesco font-ropa-sans font-rosario font-rosarivo font-rotinonhsonni-sans font-rotinonhsonni-serif font-rouge-script font-rozha-one font-ruda font-rufina font-ruge-boogie font-ruluko font-rum-raisin font-rupakara font-ruslan-display font-russo-one font-ruthie font-rye font-sadagolthina font-sail font-saira font-salsa font-samim font-sanchez font-sancreek font-sansita-one font-sarina font-sarpanch font-scada font-schoolbell font-seaweed-script font-sevillana font-seymour-one font-shabnam font-shadows-into-light font-shanti font-shojumaru font-short-stack font-siemreap font-signika-negative font-signika font-silent-lips font-sinkin-sans font-sintony font-sirin-stencil font-skranji font-slackey font-smokum font-smythe font-snippet font-snowburst-one font-sofadi-one font-sofia font-sonsie-one font-spicy-rice font-spinnaker font-spirax font-squada-one font-stalemate font-stalinist-one font-stardos-stencil font-stint-ultra-condensed font-stint-ultra-expanded font-stoke font-strait font-sue-ellen-francisco font-sunshiney font-supermercado-one font-swanky-and-moo-moo font-syncopate font-tai-le-valentinium font-taprom font-tauri font-teko font-telex font-tenor-sans font-text-me-one font-thabit font-tibetan-machine-uni font-tienne font-tillana font-tinos font-titan-one font-titillium-web font-trade-winds font-trirong font-trocchi font-trochut font-trykker font-tuffy font-ultra font-uncial-antiqua font-underdog font-unica-one font-unifrakturcook font-unifrakturmaguntia font-unkempt font-unlock font-unna font-vampiro-one font-varela font-vast-shadow font-vazir-code font-vazir font-vibur font-viga font-voces font-voltaire font-waiting-for-the-sunrise font-wakor font-wallpoet font-walter-turncoat font-waltograph font-warnes font-webdings font-wellfleet font-wendy-one font-wenquanyi-micro-hei-lite font-wonder-unit-sans font-yanone-kaffeesatz font-yeseva-one font-yesteryear font-yiddishkeit font-zeyada font-3270-nerd-font-mono

@tani
Copy link
Member

tani commented Oct 28, 2019

In terms of clarity, if you merge this request those 6 fonts can be installed:

Sounds great, thanks.

BUT unfortunately font-courier-prime-code (latest commit: Jun 15, 2019) and font-hack (latest commit: Oct 7, 2018) cannot be installed even though they are currently working. So bad! This is a rare situation, both have a directory named by font format but the problem is that it contains only one format which is unpredictable.

For this case, we have .caskignore file. So we could pin the file to success the install file.
Could you try to update .caskignore to fix commits you changed?

Due to the zip issue you mentioned, some fonts cannot be fixed without a different approach and their status doesn't change:

Okay, this issue should be pinned to our project until we solve it. At this time, you don't need to care about it. Your work already has enough value to merge our project!

Btw, have you ever considered cleaning formula directory? There are 274 fonts removed from homebrew-cask-fonts therefore some fonts will not be affected ever or some give 404 error

OMG! Thanks for noticing that. I'm going to add the cleanup script as soon as possible.

@cenksoykan
Copy link
Contributor Author

Alright, I guess ready to review

@@ -74,7 +74,7 @@ class CaskTransform < Parslet::Transform
left + " " + right
}
rule(:font => simple(:font)) {
"(share/\"fonts\").install #{replace_cask_version_properties(font.sub(/"(.*\/)/, '"../\1'))}"
"(share/\"fonts\").install #{replace_cask_version_properties(font.sub(/"((?:(?!(otf|ttf)\/)[[:blank:][:punct:]]?.)+\/)/i, '"../\1'))}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your changes seem that it is almost so nice, but this regular expression is difficult for us to read and do refactoring.
Could you tell me the meaning of the dot .after [[:blank:][:punct:]]?.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any character. Actually I don't remember why I wrote like that and what is different than
"((?:(?!(otf|ttf)\/).*)+\/) Maybe, first I wrote something
"((?:(?!(otf|ttf))[[:blank:][:punct:]]?.)+\/) and changed it little bit and forgot about...
You are totally right

Forget it for now, I will open a new PR because 🥁 I found the solution. I hope so... I suppose it will be easier.
I'm sorry for taking your time with this request

@tani
Copy link
Member

tani commented Nov 1, 2019

Closed by #17 😍

@tani tani closed this Nov 1, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working help wanted Extra attention is needed outdated
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot Install font-fira-code Unable to install font-source-code-pro
2 participants