repo_name
stringclasses 2
values | pr_number
int64 2.62k
123k
| pr_title
stringlengths 8
193
| pr_description
stringlengths 0
27.9k
| author
stringlengths 3
23
| date_created
unknown | date_merged
unknown | previous_commit
stringlengths 40
40
| pr_commit
stringlengths 40
40
| query
stringlengths 21
28k
| filepath
stringlengths 7
174
| before_content
stringlengths 0
554M
| after_content
stringlengths 0
554M
| label
int64 -1
1
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
gohugoio/hugo | 8,215 | markup/goldmark: Add attributes support for blocks (tables etc.) | Fixes #7548 | bep | "2021-02-08T09:42:41Z" | "2021-02-08T18:52:56Z" | 1b2472825664763c0b88807b0d193e73553423ec | 2681633db8d340d2dc59cf801419874d572fc704 | markup/goldmark: Add attributes support for blocks (tables etc.). Fixes #7548 | ./docs/content/en/functions/slice.md | ---
title: slice
# linktitle: slice
description: Creates a slice (array) of all passed arguments.
godocref:
date: 2017-02-01
publishdate: 2017-02-01
lastmod: 2017-02-01
categories: [functions]
menu:
docs:
parent: "functions"
keywords: [slice, array, interface]
signature: ["slice ITEM..."]
workson: []
hugoversion:
relatedfuncs: []
deprecated: false
draft: false
aliases: []
toc: false
---
One use case is the concatenation of elements in combination with the [`delimit` function][]:
{{< code file="slice.html" >}}
{{ delimit (slice "foo" "bar" "buzz") ", " }}
<!-- returns the string "foo, bar, buzz" -->
{{< /code >}}
[`delimit` function]: /functions/delimit/
| ---
title: slice
# linktitle: slice
description: Creates a slice (array) of all passed arguments.
godocref:
date: 2017-02-01
publishdate: 2017-02-01
lastmod: 2017-02-01
categories: [functions]
menu:
docs:
parent: "functions"
keywords: [slice, array, interface]
signature: ["slice ITEM..."]
workson: []
hugoversion:
relatedfuncs: []
deprecated: false
draft: false
aliases: []
toc: false
---
One use case is the concatenation of elements in combination with the [`delimit` function][]:
{{< code file="slice.html" >}}
{{ delimit (slice "foo" "bar" "buzz") ", " }}
<!-- returns the string "foo, bar, buzz" -->
{{< /code >}}
[`delimit` function]: /functions/delimit/
| -1 |
gohugoio/hugo | 8,215 | markup/goldmark: Add attributes support for blocks (tables etc.) | Fixes #7548 | bep | "2021-02-08T09:42:41Z" | "2021-02-08T18:52:56Z" | 1b2472825664763c0b88807b0d193e73553423ec | 2681633db8d340d2dc59cf801419874d572fc704 | markup/goldmark: Add attributes support for blocks (tables etc.). Fixes #7548 | ./docs/content/en/news/0.52-relnotes/index.md |
---
date: 2018-11-28
title: "And Now: Hugo 0.52"
description: "Configurable file caches, inline shortcodes, and more ..."
categories: ["Releases"]
---
The two big new items in this release is [Inline Shortcodes](https://gohugo.io//templates/shortcode-templates/#inline-shortcodes) and [Consolidated File Caches](https://gohugo.io/getting-started/configuration/#configure-file-caches). In Hugo we really care about build speed, and caching is important. With this release, you get much better control over your cache configuration, which is especially useful when building on a Continuous Integration server (Netlify, CircleCI or similar). Inline Shortcodes was implemented to help the Bootstrap project [move their documentation site](https://github.com/twbs/bootstrap/issues/24475#issuecomment-441238128) to Hugo. Note that this feature is disabled by default. To enable, set `enableInlineShortcodes = true` in your site config. Worth mentioning is also the new `param` shortcode, which looks up the param in page front matter with the site's parameter as a fall back.
This release represents **33 contributions by 7 contributors** to the main Hugo code base.
[@bep](https://github.com/bep) leads the Hugo development with a significant amount of contributions, but also a big shoutout to [@moorereason](https://github.com/moorereason), [@emirb](https://github.com/emirb), and [@allizad](https://github.com/allizad) for their ongoing contributions.
And a big thanks to [@digitalcraftsman](https://github.com/digitalcraftsman) and [@onedrawingperday](https://github.com/onedrawingperday) for their relentless work on keeping the themes site in pristine condition and to [@kaushalmodi](https://github.com/kaushalmodi) for his great work on the documentation site.
Many have also been busy writing and fixing the documentation in [hugoDocs](https://github.com/gohugoio/hugoDocs),
which has received **10 contributions by 4 contributors**. A special thanks to [@budparr](https://github.com/budparr), [@bep](https://github.com/bep), [@allizad](https://github.com/allizad), and [@funkydan2](https://github.com/funkydan2) for their work on the documentation site.
Hugo now has:
* 30595+ [stars](https://github.com/gohugoio/hugo/stargazers)
* 441+ [contributors](https://github.com/gohugoio/hugo/graphs/contributors)
* 270+ [themes](http://themes.gohugo.io/)
## Enhancements
### Templates
* Add tests [ed698e94](https://github.com/gohugoio/hugo/commit/ed698e94c12c05bfc392eaca4f0c8442eac64906) [@moorereason](https://github.com/moorereason)
* Regenerate templates [89e2716d](https://github.com/gohugoio/hugo/commit/89e2716d290708ccde0a6f65504c1650c2f41b3d) [@bep](https://github.com/bep)
* Add "param" shortcode [f37c5a25](https://github.com/gohugoio/hugo/commit/f37c5a25676db89c0e804ccaac69bb392758192b) [@bep](https://github.com/bep) [#4010](https://github.com/gohugoio/hugo/issues/4010)
* Add float64 support to where [112461fd](https://github.com/gohugoio/hugo/commit/112461fded0d7970817ce7bf476c4763922ad314) [@moorereason](https://github.com/moorereason) [#5466](https://github.com/gohugoio/hugo/issues/5466)
### Core
* Fall back to title in ByLinkTitle sort [a9a93d08](https://github.com/gohugoio/hugo/commit/a9a93d082d8640684b7fd0076c64ea808ea7f762) [@bep](https://github.com/bep) [#4953](https://github.com/gohugoio/hugo/issues/4953)
* Improve nil handling in IsDescendant and IsAncestor [b09a4033](https://github.com/gohugoio/hugo/commit/b09a40333f382cc1034d2eda856230258ab6b8cc) [@bep](https://github.com/bep) [#5461](https://github.com/gohugoio/hugo/issues/5461)
### Other
* Remove duplicate mapstructure depdendency [7e75aeca](https://github.com/gohugoio/hugo/commit/7e75aeca80aead50d64902d2ff47e4ad4d013352) [@bep](https://github.com/bep)
* Add dependency list to README [e14e0b19](https://github.com/gohugoio/hugo/commit/e14e0b192f39812e3c3d5202d34ee907021412bb) [@bep](https://github.com/bep)
* Document inline shortcodes [aded0f25](https://github.com/gohugoio/hugo/commit/aded0f25fd23a78804b10e127aebe0e4b6fed2ac) [@bep](https://github.com/bep) [#4011](https://github.com/gohugoio/hugo/issues/4011)
* Add inline shortcode support [bc337e6a](https://github.com/gohugoio/hugo/commit/bc337e6ab5a75f1f1bfe3a83f3786d0afdb6346c) [@bep](https://github.com/bep) [#4011](https://github.com/gohugoio/hugo/issues/4011)
* Include drafts in convert command [dcfeed35](https://github.com/gohugoio/hugo/commit/dcfeed35c6e14c1ce593d23be9d2b89c66ce9bee) [@bep](https://github.com/bep) [#5457](https://github.com/gohugoio/hugo/issues/5457)
* Handle themes in the new file cache (for images, assets) [f9b4eb4f](https://github.com/gohugoio/hugo/commit/f9b4eb4f3968d32f45e0168c854e6b0c7f3a90b0) [@bep](https://github.com/bep) [#5460](https://github.com/gohugoio/hugo/issues/5460)
* Add tests for permalink on Resource with baseURL with path [12742bac](https://github.com/gohugoio/hugo/commit/12742bac71c65d65dc56548b643debda94757aee) [@bep](https://github.com/bep) [#5226](https://github.com/gohugoio/hugo/issues/5226)
* Add a comment about file mode for new files [fabf026f](https://github.com/gohugoio/hugo/commit/fabf026f4937bf6fbbb944aa7d6e721839ae4c92) [@bep](https://github.com/bep) [#5434](https://github.com/gohugoio/hugo/issues/5434)
* Add a :project placeholder [94f0f7e5](https://github.com/gohugoio/hugo/commit/94f0f7e59788e802e706a55cac0d52a9e70ff745) [@bep](https://github.com/bep) [#5439](https://github.com/gohugoio/hugo/issues/5439)
* Add a cache prune func [3c29c5af](https://github.com/gohugoio/hugo/commit/3c29c5af8ee865ef20741f576088e031e940c3d2) [@bep](https://github.com/bep) [#5439](https://github.com/gohugoio/hugo/issues/5439)
* Add a filecache root dir [33502667](https://github.com/gohugoio/hugo/commit/33502667fbacf57167ede66df8f13e308a4a9aec) [@bep](https://github.com/bep)
* Use time.Duration for maxAge [d3489eba](https://github.com/gohugoio/hugo/commit/d3489eba5dfc0ecdc032016d9db0746213dd5f0e) [@bep](https://github.com/bep) [#5438](https://github.com/gohugoio/hugo/issues/5438)
* Split implementation and config into separate files [17d7ecde](https://github.com/gohugoio/hugo/commit/17d7ecde2b261d2ab29049d12361b66504e3f995) [@bep](https://github.com/bep)
* Update to LibSASS 3.5.5 [e4b25728](https://github.com/gohugoio/hugo/commit/e4b2572880550a997d51dab3b198dac1fd642690) [@bep](https://github.com/bep) [#5432](https://github.com/gohugoio/hugo/issues/5432)[#5435](https://github.com/gohugoio/hugo/issues/5435)
* More spelling corrections [782dd158](https://github.com/gohugoio/hugo/commit/782dd15858128d8dfe78970c86e543b6590a004c) [@bep](https://github.com/bep)
* Spelling corrections [aff9c091](https://github.com/gohugoio/hugo/commit/aff9c091669a022b59f493c9dccf72be29511299) [@bep](https://github.com/bep)
* Remove appveyor [fdd4a768](https://github.com/gohugoio/hugo/commit/fdd4a768f053b21271d4520bf0d43baf62d516da) [@bep](https://github.com/bep)
* Document the new file cache [abeeff13](https://github.com/gohugoio/hugo/commit/abeeff1325267f8d8f1f66f0ec4ed175ffc140ad) [@bep](https://github.com/bep) [#5404](https://github.com/gohugoio/hugo/issues/5404)
* Add a consolidated file cache [f7aeaa61](https://github.com/gohugoio/hugo/commit/f7aeaa61291dd75f92901bcbeecc7fce07a28dec) [@bep](https://github.com/bep) [#5404](https://github.com/gohugoio/hugo/issues/5404)
* Add Windows build config to Travis [7d78a2af](https://github.com/gohugoio/hugo/commit/7d78a2afd3c4a6c4af77a4ddcbd2a82f15986048) [@emirb](https://github.com/emirb)
* Add Elasticsearch/bonsai.io to services doc. [c0b3a1af](https://github.com/gohugoio/hugo/commit/c0b3a1af0354e3aa9979cc00ae8630d7f0be63dc) [@allizad](https://github.com/allizad)
## Fixes
### Templates
* Fix whitespace issue [aba2647c](https://github.com/gohugoio/hugo/commit/aba2647c152ffff927f42523b77ee6651630cd67) [@max-arnold](https://github.com/max-arnold)
* Fix test to pass with gccgo [a8cb1b07](https://github.com/gohugoio/hugo/commit/a8cb1b07b4cf7fcf0e949657cb03c1a4838f975e) [@ianlancetaylor](https://github.com/ianlancetaylor)
### Other
* Fix handling of commented out front matter [7540a628](https://github.com/gohugoio/hugo/commit/7540a62834d4465af8936967e430a9e05a1e1359) [@bep](https://github.com/bep) [#5478](https://github.com/gohugoio/hugo/issues/5478)
* Fix when only shortcode and then summary [94ab125b](https://github.com/gohugoio/hugo/commit/94ab125b27a29a65e5ea45efd99dd247084b4c37) [@bep](https://github.com/bep) [#5464](https://github.com/gohugoio/hugo/issues/5464)
* Fix ignored --config flag with 'new' command [e82b2dc8](https://github.com/gohugoio/hugo/commit/e82b2dc8c1628f2da33e5fb0bae1b03e0594ad2c) [@krisbudhram](https://github.com/krisbudhram)
* Fix Permalink for resource, baseURL with path and canonifyURLs set [5df2b79d](https://github.com/gohugoio/hugo/commit/5df2b79dd2734e9a00ed1692328f58c385676468) [@bep](https://github.com/bep) [#5226](https://github.com/gohugoio/hugo/issues/5226)
|
---
date: 2018-11-28
title: "And Now: Hugo 0.52"
description: "Configurable file caches, inline shortcodes, and more ..."
categories: ["Releases"]
---
The two big new items in this release is [Inline Shortcodes](https://gohugo.io//templates/shortcode-templates/#inline-shortcodes) and [Consolidated File Caches](https://gohugo.io/getting-started/configuration/#configure-file-caches). In Hugo we really care about build speed, and caching is important. With this release, you get much better control over your cache configuration, which is especially useful when building on a Continuous Integration server (Netlify, CircleCI or similar). Inline Shortcodes was implemented to help the Bootstrap project [move their documentation site](https://github.com/twbs/bootstrap/issues/24475#issuecomment-441238128) to Hugo. Note that this feature is disabled by default. To enable, set `enableInlineShortcodes = true` in your site config. Worth mentioning is also the new `param` shortcode, which looks up the param in page front matter with the site's parameter as a fall back.
This release represents **33 contributions by 7 contributors** to the main Hugo code base.
[@bep](https://github.com/bep) leads the Hugo development with a significant amount of contributions, but also a big shoutout to [@moorereason](https://github.com/moorereason), [@emirb](https://github.com/emirb), and [@allizad](https://github.com/allizad) for their ongoing contributions.
And a big thanks to [@digitalcraftsman](https://github.com/digitalcraftsman) and [@onedrawingperday](https://github.com/onedrawingperday) for their relentless work on keeping the themes site in pristine condition and to [@kaushalmodi](https://github.com/kaushalmodi) for his great work on the documentation site.
Many have also been busy writing and fixing the documentation in [hugoDocs](https://github.com/gohugoio/hugoDocs),
which has received **10 contributions by 4 contributors**. A special thanks to [@budparr](https://github.com/budparr), [@bep](https://github.com/bep), [@allizad](https://github.com/allizad), and [@funkydan2](https://github.com/funkydan2) for their work on the documentation site.
Hugo now has:
* 30595+ [stars](https://github.com/gohugoio/hugo/stargazers)
* 441+ [contributors](https://github.com/gohugoio/hugo/graphs/contributors)
* 270+ [themes](http://themes.gohugo.io/)
## Enhancements
### Templates
* Add tests [ed698e94](https://github.com/gohugoio/hugo/commit/ed698e94c12c05bfc392eaca4f0c8442eac64906) [@moorereason](https://github.com/moorereason)
* Regenerate templates [89e2716d](https://github.com/gohugoio/hugo/commit/89e2716d290708ccde0a6f65504c1650c2f41b3d) [@bep](https://github.com/bep)
* Add "param" shortcode [f37c5a25](https://github.com/gohugoio/hugo/commit/f37c5a25676db89c0e804ccaac69bb392758192b) [@bep](https://github.com/bep) [#4010](https://github.com/gohugoio/hugo/issues/4010)
* Add float64 support to where [112461fd](https://github.com/gohugoio/hugo/commit/112461fded0d7970817ce7bf476c4763922ad314) [@moorereason](https://github.com/moorereason) [#5466](https://github.com/gohugoio/hugo/issues/5466)
### Core
* Fall back to title in ByLinkTitle sort [a9a93d08](https://github.com/gohugoio/hugo/commit/a9a93d082d8640684b7fd0076c64ea808ea7f762) [@bep](https://github.com/bep) [#4953](https://github.com/gohugoio/hugo/issues/4953)
* Improve nil handling in IsDescendant and IsAncestor [b09a4033](https://github.com/gohugoio/hugo/commit/b09a40333f382cc1034d2eda856230258ab6b8cc) [@bep](https://github.com/bep) [#5461](https://github.com/gohugoio/hugo/issues/5461)
### Other
* Remove duplicate mapstructure depdendency [7e75aeca](https://github.com/gohugoio/hugo/commit/7e75aeca80aead50d64902d2ff47e4ad4d013352) [@bep](https://github.com/bep)
* Add dependency list to README [e14e0b19](https://github.com/gohugoio/hugo/commit/e14e0b192f39812e3c3d5202d34ee907021412bb) [@bep](https://github.com/bep)
* Document inline shortcodes [aded0f25](https://github.com/gohugoio/hugo/commit/aded0f25fd23a78804b10e127aebe0e4b6fed2ac) [@bep](https://github.com/bep) [#4011](https://github.com/gohugoio/hugo/issues/4011)
* Add inline shortcode support [bc337e6a](https://github.com/gohugoio/hugo/commit/bc337e6ab5a75f1f1bfe3a83f3786d0afdb6346c) [@bep](https://github.com/bep) [#4011](https://github.com/gohugoio/hugo/issues/4011)
* Include drafts in convert command [dcfeed35](https://github.com/gohugoio/hugo/commit/dcfeed35c6e14c1ce593d23be9d2b89c66ce9bee) [@bep](https://github.com/bep) [#5457](https://github.com/gohugoio/hugo/issues/5457)
* Handle themes in the new file cache (for images, assets) [f9b4eb4f](https://github.com/gohugoio/hugo/commit/f9b4eb4f3968d32f45e0168c854e6b0c7f3a90b0) [@bep](https://github.com/bep) [#5460](https://github.com/gohugoio/hugo/issues/5460)
* Add tests for permalink on Resource with baseURL with path [12742bac](https://github.com/gohugoio/hugo/commit/12742bac71c65d65dc56548b643debda94757aee) [@bep](https://github.com/bep) [#5226](https://github.com/gohugoio/hugo/issues/5226)
* Add a comment about file mode for new files [fabf026f](https://github.com/gohugoio/hugo/commit/fabf026f4937bf6fbbb944aa7d6e721839ae4c92) [@bep](https://github.com/bep) [#5434](https://github.com/gohugoio/hugo/issues/5434)
* Add a :project placeholder [94f0f7e5](https://github.com/gohugoio/hugo/commit/94f0f7e59788e802e706a55cac0d52a9e70ff745) [@bep](https://github.com/bep) [#5439](https://github.com/gohugoio/hugo/issues/5439)
* Add a cache prune func [3c29c5af](https://github.com/gohugoio/hugo/commit/3c29c5af8ee865ef20741f576088e031e940c3d2) [@bep](https://github.com/bep) [#5439](https://github.com/gohugoio/hugo/issues/5439)
* Add a filecache root dir [33502667](https://github.com/gohugoio/hugo/commit/33502667fbacf57167ede66df8f13e308a4a9aec) [@bep](https://github.com/bep)
* Use time.Duration for maxAge [d3489eba](https://github.com/gohugoio/hugo/commit/d3489eba5dfc0ecdc032016d9db0746213dd5f0e) [@bep](https://github.com/bep) [#5438](https://github.com/gohugoio/hugo/issues/5438)
* Split implementation and config into separate files [17d7ecde](https://github.com/gohugoio/hugo/commit/17d7ecde2b261d2ab29049d12361b66504e3f995) [@bep](https://github.com/bep)
* Update to LibSASS 3.5.5 [e4b25728](https://github.com/gohugoio/hugo/commit/e4b2572880550a997d51dab3b198dac1fd642690) [@bep](https://github.com/bep) [#5432](https://github.com/gohugoio/hugo/issues/5432)[#5435](https://github.com/gohugoio/hugo/issues/5435)
* More spelling corrections [782dd158](https://github.com/gohugoio/hugo/commit/782dd15858128d8dfe78970c86e543b6590a004c) [@bep](https://github.com/bep)
* Spelling corrections [aff9c091](https://github.com/gohugoio/hugo/commit/aff9c091669a022b59f493c9dccf72be29511299) [@bep](https://github.com/bep)
* Remove appveyor [fdd4a768](https://github.com/gohugoio/hugo/commit/fdd4a768f053b21271d4520bf0d43baf62d516da) [@bep](https://github.com/bep)
* Document the new file cache [abeeff13](https://github.com/gohugoio/hugo/commit/abeeff1325267f8d8f1f66f0ec4ed175ffc140ad) [@bep](https://github.com/bep) [#5404](https://github.com/gohugoio/hugo/issues/5404)
* Add a consolidated file cache [f7aeaa61](https://github.com/gohugoio/hugo/commit/f7aeaa61291dd75f92901bcbeecc7fce07a28dec) [@bep](https://github.com/bep) [#5404](https://github.com/gohugoio/hugo/issues/5404)
* Add Windows build config to Travis [7d78a2af](https://github.com/gohugoio/hugo/commit/7d78a2afd3c4a6c4af77a4ddcbd2a82f15986048) [@emirb](https://github.com/emirb)
* Add Elasticsearch/bonsai.io to services doc. [c0b3a1af](https://github.com/gohugoio/hugo/commit/c0b3a1af0354e3aa9979cc00ae8630d7f0be63dc) [@allizad](https://github.com/allizad)
## Fixes
### Templates
* Fix whitespace issue [aba2647c](https://github.com/gohugoio/hugo/commit/aba2647c152ffff927f42523b77ee6651630cd67) [@max-arnold](https://github.com/max-arnold)
* Fix test to pass with gccgo [a8cb1b07](https://github.com/gohugoio/hugo/commit/a8cb1b07b4cf7fcf0e949657cb03c1a4838f975e) [@ianlancetaylor](https://github.com/ianlancetaylor)
### Other
* Fix handling of commented out front matter [7540a628](https://github.com/gohugoio/hugo/commit/7540a62834d4465af8936967e430a9e05a1e1359) [@bep](https://github.com/bep) [#5478](https://github.com/gohugoio/hugo/issues/5478)
* Fix when only shortcode and then summary [94ab125b](https://github.com/gohugoio/hugo/commit/94ab125b27a29a65e5ea45efd99dd247084b4c37) [@bep](https://github.com/bep) [#5464](https://github.com/gohugoio/hugo/issues/5464)
* Fix ignored --config flag with 'new' command [e82b2dc8](https://github.com/gohugoio/hugo/commit/e82b2dc8c1628f2da33e5fb0bae1b03e0594ad2c) [@krisbudhram](https://github.com/krisbudhram)
* Fix Permalink for resource, baseURL with path and canonifyURLs set [5df2b79d](https://github.com/gohugoio/hugo/commit/5df2b79dd2734e9a00ed1692328f58c385676468) [@bep](https://github.com/bep) [#5226](https://github.com/gohugoio/hugo/issues/5226)
| -1 |
gohugoio/hugo | 8,215 | markup/goldmark: Add attributes support for blocks (tables etc.) | Fixes #7548 | bep | "2021-02-08T09:42:41Z" | "2021-02-08T18:52:56Z" | 1b2472825664763c0b88807b0d193e73553423ec | 2681633db8d340d2dc59cf801419874d572fc704 | markup/goldmark: Add attributes support for blocks (tables etc.). Fixes #7548 | ./docs/content/en/news/0.11-relnotes/index.md | ---
date: 2014-05-29T22:53:22Z
description: "Now 3–4 times faster, Hugo 0.11 brings live reload, theme engine, menu system, XML sitemap, and more!"
title: "Hugo 0.11"
categories: ["Releases"]
---
- Considerably faster... about 3 - 4x faster on average
- [Live Reload](/getting-started/usage/#livereload). Hugo will automatically reload the browser when the build is complete
- Theme engine w/[Theme Repository](http://github.com/spf13/hugoThemes)
- [Menu system](/content-management/menus/) with support for active page
- [Builders](/extras/builders) to quickly create a new site, content or theme
- [XML sitemap](/templates/sitemap) generation
- [Integrated Disqus](/extras/comments) support
- Streamlined [template organization](/templates/overview)
- Brand new docs site
- Support for publishDate which allows for posts to be dated in the future
- More [sort](/functions/sort/#readout) options
- Logging support
- Much better error handling
- More informative verbose output
- Renamed Indexes > [Taxonomies](/taxonomies/overview)
- Renamed Chrome > [Partials](/templates/partials)
| ---
date: 2014-05-29T22:53:22Z
description: "Now 3–4 times faster, Hugo 0.11 brings live reload, theme engine, menu system, XML sitemap, and more!"
title: "Hugo 0.11"
categories: ["Releases"]
---
- Considerably faster... about 3 - 4x faster on average
- [Live Reload](/getting-started/usage/#livereload). Hugo will automatically reload the browser when the build is complete
- Theme engine w/[Theme Repository](http://github.com/spf13/hugoThemes)
- [Menu system](/content-management/menus/) with support for active page
- [Builders](/extras/builders) to quickly create a new site, content or theme
- [XML sitemap](/templates/sitemap) generation
- [Integrated Disqus](/extras/comments) support
- Streamlined [template organization](/templates/overview)
- Brand new docs site
- Support for publishDate which allows for posts to be dated in the future
- More [sort](/functions/sort/#readout) options
- Logging support
- Much better error handling
- More informative verbose output
- Renamed Indexes > [Taxonomies](/taxonomies/overview)
- Renamed Chrome > [Partials](/templates/partials)
| -1 |
gohugoio/hugo | 8,215 | markup/goldmark: Add attributes support for blocks (tables etc.) | Fixes #7548 | bep | "2021-02-08T09:42:41Z" | "2021-02-08T18:52:56Z" | 1b2472825664763c0b88807b0d193e73553423ec | 2681633db8d340d2dc59cf801419874d572fc704 | markup/goldmark: Add attributes support for blocks (tables etc.). Fixes #7548 | ./docs/content/en/hosting-and-deployment/hosting-on-firebase.md | ---
title: Host on Firebase
linktitle: Host on Firebase
description: You can use Firebase's free tier to host your static website; this also gives you access to Firebase's NOSQL API.
date: 2017-03-12
publishdate: 2017-03-12
lastmod: 2017-03-15
categories: [hosting and deployment]
keywords: [hosting,firebase]
authors: [Michel Racic]
menu:
docs:
parent: "hosting-and-deployment"
weight: 20
weight: 20
sections_weight: 20
draft: false
toc: true
aliases: []
---
## Assumptions
1. You have an account with [Firebase][signup]. (If you don't, you can sign up for free using your Google account.)
2. You have completed the [Quick Start][] or have a completed Hugo website ready for deployment.
## Initial setup
Go to the [Firebase console][console] and create a new project (unless you already have a project). You will need to globally install `firebase-tools` (node.js):
```
npm install -g firebase-tools
```
Log in to Firebase (setup on your local machine) using `firebase login`, which opens a browser where you can select your account. Use `firebase logout` in case you are already logged in but to the wrong account.
```
firebase login
```
In the root of your Hugo project, initialize the Firebase project with the `firebase init` command:
```
firebase init
```
From here:
1. Choose Hosting in the feature question
2. Choose the project you just set up
3. Accept the default for your database rules file
4. Accept the default for the publish directory, which is `public`
5. Choose "No" in the question if you are deploying a single-page app
## Deploy
To deploy your Hugo site, execute the `firebase deploy` command, and your site will be up in no time:
```
hugo && firebase deploy
```
## CI Setup
You can generate a deploy token using
```
firebase login:ci
```
You can also set up your CI (e.g., with [Wercker][]) and add the token to a private variable like `$FIREBASE_DEPLOY_TOKEN`.
{{% note %}}
This is a private secret and it should not appear in a public repository. Make sure you understand your chosen CI and that it's not visible to others.
{{% /note %}}
You can then add a step in your build to do the deployment using the token:
```
firebase deploy --token $FIREBASE_DEPLOY_TOKEN
```
## Reference links
* [Firebase CLI Reference](https://firebase.google.com/docs/cli/#administrative_commands)
[console]: https://console.firebase.google.com
[Quick Start]: /getting-started/quick-start/
[signup]: https://console.firebase.google.com/
[Wercker]: /hosting-and-deployment/deployment-with-wercker/
| ---
title: Host on Firebase
linktitle: Host on Firebase
description: You can use Firebase's free tier to host your static website; this also gives you access to Firebase's NOSQL API.
date: 2017-03-12
publishdate: 2017-03-12
lastmod: 2017-03-15
categories: [hosting and deployment]
keywords: [hosting,firebase]
authors: [Michel Racic]
menu:
docs:
parent: "hosting-and-deployment"
weight: 20
weight: 20
sections_weight: 20
draft: false
toc: true
aliases: []
---
## Assumptions
1. You have an account with [Firebase][signup]. (If you don't, you can sign up for free using your Google account.)
2. You have completed the [Quick Start][] or have a completed Hugo website ready for deployment.
## Initial setup
Go to the [Firebase console][console] and create a new project (unless you already have a project). You will need to globally install `firebase-tools` (node.js):
```
npm install -g firebase-tools
```
Log in to Firebase (setup on your local machine) using `firebase login`, which opens a browser where you can select your account. Use `firebase logout` in case you are already logged in but to the wrong account.
```
firebase login
```
In the root of your Hugo project, initialize the Firebase project with the `firebase init` command:
```
firebase init
```
From here:
1. Choose Hosting in the feature question
2. Choose the project you just set up
3. Accept the default for your database rules file
4. Accept the default for the publish directory, which is `public`
5. Choose "No" in the question if you are deploying a single-page app
## Deploy
To deploy your Hugo site, execute the `firebase deploy` command, and your site will be up in no time:
```
hugo && firebase deploy
```
## CI Setup
You can generate a deploy token using
```
firebase login:ci
```
You can also set up your CI (e.g., with [Wercker][]) and add the token to a private variable like `$FIREBASE_DEPLOY_TOKEN`.
{{% note %}}
This is a private secret and it should not appear in a public repository. Make sure you understand your chosen CI and that it's not visible to others.
{{% /note %}}
You can then add a step in your build to do the deployment using the token:
```
firebase deploy --token $FIREBASE_DEPLOY_TOKEN
```
## Reference links
* [Firebase CLI Reference](https://firebase.google.com/docs/cli/#administrative_commands)
[console]: https://console.firebase.google.com
[Quick Start]: /getting-started/quick-start/
[signup]: https://console.firebase.google.com/
[Wercker]: /hosting-and-deployment/deployment-with-wercker/
| -1 |
gohugoio/hugo | 8,215 | markup/goldmark: Add attributes support for blocks (tables etc.) | Fixes #7548 | bep | "2021-02-08T09:42:41Z" | "2021-02-08T18:52:56Z" | 1b2472825664763c0b88807b0d193e73553423ec | 2681633db8d340d2dc59cf801419874d572fc704 | markup/goldmark: Add attributes support for blocks (tables etc.). Fixes #7548 | ./common/hugio/copy.go | // Copyright 2019 The Hugo Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package hugio
import (
"io"
"io/ioutil"
"os"
"path/filepath"
"github.com/pkg/errors"
"github.com/spf13/afero"
)
// CopyFile copies a file.
func CopyFile(fs afero.Fs, from, to string) error {
sf, err := fs.Open(from)
if err != nil {
return err
}
defer sf.Close()
df, err := fs.Create(to)
if err != nil {
return err
}
defer df.Close()
_, err = io.Copy(df, sf)
if err != nil {
return err
}
si, err := fs.Stat(from)
if err != nil {
err = fs.Chmod(to, si.Mode())
if err != nil {
return err
}
}
return nil
}
// CopyDir copies a directory.
func CopyDir(fs afero.Fs, from, to string, shouldCopy func(filename string) bool) error {
fi, err := os.Stat(from)
if err != nil {
return err
}
if !fi.IsDir() {
return errors.Errorf("%q is not a directory", from)
}
err = fs.MkdirAll(to, 0777) // before umask
if err != nil {
return err
}
entries, _ := ioutil.ReadDir(from)
for _, entry := range entries {
fromFilename := filepath.Join(from, entry.Name())
toFilename := filepath.Join(to, entry.Name())
if entry.IsDir() {
if shouldCopy != nil && !shouldCopy(fromFilename) {
continue
}
if err := CopyDir(fs, fromFilename, toFilename, shouldCopy); err != nil {
return err
}
} else {
if err := CopyFile(fs, fromFilename, toFilename); err != nil {
return err
}
}
}
return nil
}
| // Copyright 2019 The Hugo Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package hugio
import (
"io"
"io/ioutil"
"os"
"path/filepath"
"github.com/pkg/errors"
"github.com/spf13/afero"
)
// CopyFile copies a file.
func CopyFile(fs afero.Fs, from, to string) error {
sf, err := fs.Open(from)
if err != nil {
return err
}
defer sf.Close()
df, err := fs.Create(to)
if err != nil {
return err
}
defer df.Close()
_, err = io.Copy(df, sf)
if err != nil {
return err
}
si, err := fs.Stat(from)
if err != nil {
err = fs.Chmod(to, si.Mode())
if err != nil {
return err
}
}
return nil
}
// CopyDir copies a directory.
func CopyDir(fs afero.Fs, from, to string, shouldCopy func(filename string) bool) error {
fi, err := os.Stat(from)
if err != nil {
return err
}
if !fi.IsDir() {
return errors.Errorf("%q is not a directory", from)
}
err = fs.MkdirAll(to, 0777) // before umask
if err != nil {
return err
}
entries, _ := ioutil.ReadDir(from)
for _, entry := range entries {
fromFilename := filepath.Join(from, entry.Name())
toFilename := filepath.Join(to, entry.Name())
if entry.IsDir() {
if shouldCopy != nil && !shouldCopy(fromFilename) {
continue
}
if err := CopyDir(fs, fromFilename, toFilename, shouldCopy); err != nil {
return err
}
} else {
if err := CopyFile(fs, fromFilename, toFilename); err != nil {
return err
}
}
}
return nil
}
| -1 |
gohugoio/hugo | 8,215 | markup/goldmark: Add attributes support for blocks (tables etc.) | Fixes #7548 | bep | "2021-02-08T09:42:41Z" | "2021-02-08T18:52:56Z" | 1b2472825664763c0b88807b0d193e73553423ec | 2681633db8d340d2dc59cf801419874d572fc704 | markup/goldmark: Add attributes support for blocks (tables etc.). Fixes #7548 | ./tpl/transform/init_test.go | // Copyright 2017 The Hugo Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package transform
import (
"testing"
qt "github.com/frankban/quicktest"
"github.com/gohugoio/hugo/deps"
"github.com/gohugoio/hugo/htesting/hqt"
"github.com/gohugoio/hugo/tpl/internal"
)
func TestInit(t *testing.T) {
c := qt.New(t)
var found bool
var ns *internal.TemplateFuncsNamespace
for _, nsf := range internal.TemplateFuncsNamespaceRegistry {
ns = nsf(&deps.Deps{})
if ns.Name == name {
found = true
break
}
}
c.Assert(found, qt.Equals, true)
c.Assert(ns.Context(), hqt.IsSameType, &Namespace{})
}
| // Copyright 2017 The Hugo Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package transform
import (
"testing"
qt "github.com/frankban/quicktest"
"github.com/gohugoio/hugo/deps"
"github.com/gohugoio/hugo/htesting/hqt"
"github.com/gohugoio/hugo/tpl/internal"
)
func TestInit(t *testing.T) {
c := qt.New(t)
var found bool
var ns *internal.TemplateFuncsNamespace
for _, nsf := range internal.TemplateFuncsNamespaceRegistry {
ns = nsf(&deps.Deps{})
if ns.Name == name {
found = true
break
}
}
c.Assert(found, qt.Equals, true)
c.Assert(ns.Context(), hqt.IsSameType, &Namespace{})
}
| -1 |
gohugoio/hugo | 8,215 | markup/goldmark: Add attributes support for blocks (tables etc.) | Fixes #7548 | bep | "2021-02-08T09:42:41Z" | "2021-02-08T18:52:56Z" | 1b2472825664763c0b88807b0d193e73553423ec | 2681633db8d340d2dc59cf801419874d572fc704 | markup/goldmark: Add attributes support for blocks (tables etc.). Fixes #7548 | ./tpl/internal/go_templates/htmltemplate/attr_string.go | // Code generated by "stringer -type attr"; DO NOT EDIT.
package template
import "strconv"
const _attr_name = "attrNoneattrScriptattrScriptTypeattrStyleattrURLattrSrcset"
var _attr_index = [...]uint8{0, 8, 18, 32, 41, 48, 58}
func (i attr) String() string {
if i >= attr(len(_attr_index)-1) {
return "attr(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _attr_name[_attr_index[i]:_attr_index[i+1]]
}
| // Code generated by "stringer -type attr"; DO NOT EDIT.
package template
import "strconv"
const _attr_name = "attrNoneattrScriptattrScriptTypeattrStyleattrURLattrSrcset"
var _attr_index = [...]uint8{0, 8, 18, 32, 41, 48, 58}
func (i attr) String() string {
if i >= attr(len(_attr_index)-1) {
return "attr(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _attr_name[_attr_index[i]:_attr_index[i+1]]
}
| -1 |
gohugoio/hugo | 8,215 | markup/goldmark: Add attributes support for blocks (tables etc.) | Fixes #7548 | bep | "2021-02-08T09:42:41Z" | "2021-02-08T18:52:56Z" | 1b2472825664763c0b88807b0d193e73553423ec | 2681633db8d340d2dc59cf801419874d572fc704 | markup/goldmark: Add attributes support for blocks (tables etc.). Fixes #7548 | ./deploy/deploy_test.go | // Copyright 2019 The Hugo Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// +build !nodeploy
package deploy
import (
"bytes"
"compress/gzip"
"context"
"crypto/md5"
"fmt"
"io"
"io/ioutil"
"os"
"path"
"path/filepath"
"regexp"
"sort"
"testing"
"github.com/gohugoio/hugo/media"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/spf13/afero"
"gocloud.dev/blob"
"gocloud.dev/blob/fileblob"
"gocloud.dev/blob/memblob"
)
func TestFindDiffs(t *testing.T) {
hash1 := []byte("hash 1")
hash2 := []byte("hash 2")
makeLocal := func(path string, size int64, hash []byte) *localFile {
return &localFile{NativePath: path, SlashPath: filepath.ToSlash(path), UploadSize: size, md5: hash}
}
makeRemote := func(path string, size int64, hash []byte) *blob.ListObject {
return &blob.ListObject{Key: path, Size: size, MD5: hash}
}
tests := []struct {
Description string
Local []*localFile
Remote []*blob.ListObject
Force bool
WantUpdates []*fileToUpload
WantDeletes []string
}{
{
Description: "empty -> no diffs",
},
{
Description: "local == remote -> no diffs",
Local: []*localFile{
makeLocal("aaa", 1, hash1),
makeLocal("bbb", 2, hash1),
makeLocal("ccc", 3, hash2),
},
Remote: []*blob.ListObject{
makeRemote("aaa", 1, hash1),
makeRemote("bbb", 2, hash1),
makeRemote("ccc", 3, hash2),
},
},
{
Description: "local w/ separators == remote -> no diffs",
Local: []*localFile{
makeLocal(filepath.Join("aaa", "aaa"), 1, hash1),
makeLocal(filepath.Join("bbb", "bbb"), 2, hash1),
makeLocal(filepath.Join("ccc", "ccc"), 3, hash2),
},
Remote: []*blob.ListObject{
makeRemote("aaa/aaa", 1, hash1),
makeRemote("bbb/bbb", 2, hash1),
makeRemote("ccc/ccc", 3, hash2),
},
},
{
Description: "local == remote with force flag true -> diffs",
Local: []*localFile{
makeLocal("aaa", 1, hash1),
makeLocal("bbb", 2, hash1),
makeLocal("ccc", 3, hash2),
},
Remote: []*blob.ListObject{
makeRemote("aaa", 1, hash1),
makeRemote("bbb", 2, hash1),
makeRemote("ccc", 3, hash2),
},
Force: true,
WantUpdates: []*fileToUpload{
{makeLocal("aaa", 1, nil), reasonForce},
{makeLocal("bbb", 2, nil), reasonForce},
{makeLocal("ccc", 3, nil), reasonForce},
},
},
{
Description: "local == remote with route.Force true -> diffs",
Local: []*localFile{
{NativePath: "aaa", SlashPath: "aaa", UploadSize: 1, matcher: &matcher{Force: true}, md5: hash1},
makeLocal("bbb", 2, hash1),
},
Remote: []*blob.ListObject{
makeRemote("aaa", 1, hash1),
makeRemote("bbb", 2, hash1),
},
WantUpdates: []*fileToUpload{
{makeLocal("aaa", 1, nil), reasonForce},
},
},
{
Description: "extra local file -> upload",
Local: []*localFile{
makeLocal("aaa", 1, hash1),
makeLocal("bbb", 2, hash2),
},
Remote: []*blob.ListObject{
makeRemote("aaa", 1, hash1),
},
WantUpdates: []*fileToUpload{
{makeLocal("bbb", 2, nil), reasonNotFound},
},
},
{
Description: "extra remote file -> delete",
Local: []*localFile{
makeLocal("aaa", 1, hash1),
},
Remote: []*blob.ListObject{
makeRemote("aaa", 1, hash1),
makeRemote("bbb", 2, hash2),
},
WantDeletes: []string{"bbb"},
},
{
Description: "diffs in size or md5 -> upload",
Local: []*localFile{
makeLocal("aaa", 1, hash1),
makeLocal("bbb", 2, hash1),
makeLocal("ccc", 1, hash2),
},
Remote: []*blob.ListObject{
makeRemote("aaa", 1, nil),
makeRemote("bbb", 1, hash1),
makeRemote("ccc", 1, hash1),
},
WantUpdates: []*fileToUpload{
{makeLocal("aaa", 1, nil), reasonMD5Missing},
{makeLocal("bbb", 2, nil), reasonSize},
{makeLocal("ccc", 1, nil), reasonMD5Differs},
},
},
{
Description: "mix of updates and deletes",
Local: []*localFile{
makeLocal("same", 1, hash1),
makeLocal("updated", 2, hash1),
makeLocal("updated2", 1, hash2),
makeLocal("new", 1, hash1),
makeLocal("new2", 2, hash2),
},
Remote: []*blob.ListObject{
makeRemote("same", 1, hash1),
makeRemote("updated", 1, hash1),
makeRemote("updated2", 1, hash1),
makeRemote("stale", 1, hash1),
makeRemote("stale2", 1, hash1),
},
WantUpdates: []*fileToUpload{
{makeLocal("new", 1, nil), reasonNotFound},
{makeLocal("new2", 2, nil), reasonNotFound},
{makeLocal("updated", 2, nil), reasonSize},
{makeLocal("updated2", 1, nil), reasonMD5Differs},
},
WantDeletes: []string{"stale", "stale2"},
},
}
for _, tc := range tests {
t.Run(tc.Description, func(t *testing.T) {
local := map[string]*localFile{}
for _, l := range tc.Local {
local[l.SlashPath] = l
}
remote := map[string]*blob.ListObject{}
for _, r := range tc.Remote {
remote[r.Key] = r
}
gotUpdates, gotDeletes := findDiffs(local, remote, tc.Force)
gotUpdates = applyOrdering(nil, gotUpdates)[0]
sort.Slice(gotDeletes, func(i, j int) bool { return gotDeletes[i] < gotDeletes[j] })
if diff := cmp.Diff(gotUpdates, tc.WantUpdates, cmpopts.IgnoreUnexported(localFile{})); diff != "" {
t.Errorf("updates differ:\n%s", diff)
}
if diff := cmp.Diff(gotDeletes, tc.WantDeletes); diff != "" {
t.Errorf("deletes differ:\n%s", diff)
}
})
}
}
func TestWalkLocal(t *testing.T) {
tests := map[string]struct {
Given []string
Expect []string
}{
"Empty": {
Given: []string{},
Expect: []string{},
},
"Normal": {
Given: []string{"file.txt", "normal_dir/file.txt"},
Expect: []string{"file.txt", "normal_dir/file.txt"},
},
"Hidden": {
Given: []string{"file.txt", ".hidden_dir/file.txt", "normal_dir/file.txt"},
Expect: []string{"file.txt", "normal_dir/file.txt"},
},
"Well Known": {
Given: []string{"file.txt", ".hidden_dir/file.txt", ".well-known/file.txt"},
Expect: []string{"file.txt", ".well-known/file.txt"},
},
}
for desc, tc := range tests {
t.Run(desc, func(t *testing.T) {
fs := afero.NewMemMapFs()
for _, name := range tc.Given {
dir, _ := path.Split(name)
if dir != "" {
if err := fs.MkdirAll(dir, 0755); err != nil {
t.Fatal(err)
}
}
if fd, err := fs.Create(name); err != nil {
t.Fatal(err)
} else {
fd.Close()
}
}
if got, err := walkLocal(fs, nil, nil, nil, media.DefaultTypes); err != nil {
t.Fatal(err)
} else {
expect := map[string]interface{}{}
for _, path := range tc.Expect {
if _, ok := got[path]; !ok {
t.Errorf("expected %q in results, but was not found", path)
}
expect[path] = nil
}
for path := range got {
if _, ok := expect[path]; !ok {
t.Errorf("got %q in results unexpectedly", path)
}
}
}
})
}
}
func TestLocalFile(t *testing.T) {
const (
content = "hello world!"
)
contentBytes := []byte(content)
contentLen := int64(len(contentBytes))
contentMD5 := md5.Sum(contentBytes)
var buf bytes.Buffer
gz := gzip.NewWriter(&buf)
if _, err := gz.Write(contentBytes); err != nil {
t.Fatal(err)
}
gz.Close()
gzBytes := buf.Bytes()
gzLen := int64(len(gzBytes))
gzMD5 := md5.Sum(gzBytes)
tests := []struct {
Description string
Path string
Matcher *matcher
MediaTypesConfig []map[string]interface{}
WantContent []byte
WantSize int64
WantMD5 []byte
WantContentType string // empty string is always OK, since content type detection is OS-specific
WantCacheControl string
WantContentEncoding string
}{
{
Description: "file with no suffix",
Path: "foo",
WantContent: contentBytes,
WantSize: contentLen,
WantMD5: contentMD5[:],
},
{
Description: "file with .txt suffix",
Path: "foo.txt",
WantContent: contentBytes,
WantSize: contentLen,
WantMD5: contentMD5[:],
},
{
Description: "CacheControl from matcher",
Path: "foo.txt",
Matcher: &matcher{CacheControl: "max-age=630720000"},
WantContent: contentBytes,
WantSize: contentLen,
WantMD5: contentMD5[:],
WantCacheControl: "max-age=630720000",
},
{
Description: "ContentEncoding from matcher",
Path: "foo.txt",
Matcher: &matcher{ContentEncoding: "foobar"},
WantContent: contentBytes,
WantSize: contentLen,
WantMD5: contentMD5[:],
WantContentEncoding: "foobar",
},
{
Description: "ContentType from matcher",
Path: "foo.txt",
Matcher: &matcher{ContentType: "foo/bar"},
WantContent: contentBytes,
WantSize: contentLen,
WantMD5: contentMD5[:],
WantContentType: "foo/bar",
},
{
Description: "gzipped content",
Path: "foo.txt",
Matcher: &matcher{Gzip: true},
WantContent: gzBytes,
WantSize: gzLen,
WantMD5: gzMD5[:],
WantContentEncoding: "gzip",
},
{
Description: "Custom MediaType",
Path: "foo.hugo",
MediaTypesConfig: []map[string]interface{}{
{
"hugo/custom": map[string]interface{}{
"suffixes": []string{"hugo"},
},
},
},
WantContent: contentBytes,
WantSize: contentLen,
WantMD5: contentMD5[:],
WantContentType: "hugo/custom",
},
}
for _, tc := range tests {
t.Run(tc.Description, func(t *testing.T) {
fs := new(afero.MemMapFs)
if err := afero.WriteFile(fs, tc.Path, []byte(content), os.ModePerm); err != nil {
t.Fatal(err)
}
mediaTypes := media.DefaultTypes
if len(tc.MediaTypesConfig) > 0 {
mt, err := media.DecodeTypes(tc.MediaTypesConfig...)
if err != nil {
t.Fatal(err)
}
mediaTypes = mt
}
lf, err := newLocalFile(fs, tc.Path, filepath.ToSlash(tc.Path), tc.Matcher, mediaTypes)
if err != nil {
t.Fatal(err)
}
if got := lf.UploadSize; got != tc.WantSize {
t.Errorf("got size %d want %d", got, tc.WantSize)
}
if got := lf.MD5(); !bytes.Equal(got, tc.WantMD5) {
t.Errorf("got MD5 %x want %x", got, tc.WantMD5)
}
if got := lf.CacheControl(); got != tc.WantCacheControl {
t.Errorf("got CacheControl %q want %q", got, tc.WantCacheControl)
}
if got := lf.ContentEncoding(); got != tc.WantContentEncoding {
t.Errorf("got ContentEncoding %q want %q", got, tc.WantContentEncoding)
}
if tc.WantContentType != "" {
if got := lf.ContentType(); got != tc.WantContentType {
t.Errorf("got ContentType %q want %q", got, tc.WantContentType)
}
}
// Verify the reader last to ensure the previous operations don't
// interfere with it.
r, err := lf.Reader()
if err != nil {
t.Fatal(err)
}
gotContent, err := ioutil.ReadAll(r)
if err != nil {
t.Fatal(err)
}
if !bytes.Equal(gotContent, tc.WantContent) {
t.Errorf("got content %q want %q", string(gotContent), string(tc.WantContent))
}
r.Close()
// Verify we can read again.
r, err = lf.Reader()
if err != nil {
t.Fatal(err)
}
gotContent, err = ioutil.ReadAll(r)
if err != nil {
t.Fatal(err)
}
r.Close()
if !bytes.Equal(gotContent, tc.WantContent) {
t.Errorf("got content %q want %q", string(gotContent), string(tc.WantContent))
}
})
}
}
func TestOrdering(t *testing.T) {
tests := []struct {
Description string
Uploads []string
Ordering []*regexp.Regexp
Want [][]string
}{
{
Description: "empty",
Want: [][]string{nil},
},
{
Description: "no ordering",
Uploads: []string{"c", "b", "a", "d"},
Want: [][]string{{"a", "b", "c", "d"}},
},
{
Description: "one ordering",
Uploads: []string{"db", "c", "b", "a", "da"},
Ordering: []*regexp.Regexp{regexp.MustCompile("^d")},
Want: [][]string{{"da", "db"}, {"a", "b", "c"}},
},
{
Description: "two orderings",
Uploads: []string{"db", "c", "b", "a", "da"},
Ordering: []*regexp.Regexp{
regexp.MustCompile("^d"),
regexp.MustCompile("^b"),
},
Want: [][]string{{"da", "db"}, {"b"}, {"a", "c"}},
},
}
for _, tc := range tests {
t.Run(tc.Description, func(t *testing.T) {
uploads := make([]*fileToUpload, len(tc.Uploads))
for i, u := range tc.Uploads {
uploads[i] = &fileToUpload{Local: &localFile{SlashPath: u}}
}
gotUploads := applyOrdering(tc.Ordering, uploads)
var got [][]string
for _, subslice := range gotUploads {
var gotsubslice []string
for _, u := range subslice {
gotsubslice = append(gotsubslice, u.Local.SlashPath)
}
got = append(got, gotsubslice)
}
if diff := cmp.Diff(got, tc.Want); diff != "" {
t.Error(diff)
}
})
}
}
type fileData struct {
Name string // name of the file
Contents string // contents of the file
}
// initLocalFs initializes fs with some test files.
func initLocalFs(ctx context.Context, fs afero.Fs) ([]*fileData, error) {
// The initial local filesystem.
local := []*fileData{
{"aaa", "aaa"},
{"bbb", "bbb"},
{"subdir/aaa", "subdir-aaa"},
{"subdir/nested/aaa", "subdir-nested-aaa"},
{"subdir2/bbb", "subdir2-bbb"},
}
if err := writeFiles(fs, local); err != nil {
return nil, err
}
return local, nil
}
// fsTest represents an (afero.FS, Go CDK blob.Bucket) against which end-to-end
// tests can be run.
type fsTest struct {
name string
fs afero.Fs
bucket *blob.Bucket
}
// initFsTests initializes a pair of tests for end-to-end test:
// 1. An in-memory afero.Fs paired with an in-memory Go CDK bucket.
// 2. A filesystem-based afero.Fs paired with an filesystem-based Go CDK bucket.
// It returns the pair of tests and a cleanup function.
func initFsTests() ([]*fsTest, func(), error) {
tmpfsdir, err := ioutil.TempDir("", "fs")
if err != nil {
return nil, nil, err
}
tmpbucketdir, err := ioutil.TempDir("", "bucket")
if err != nil {
return nil, nil, err
}
memfs := afero.NewMemMapFs()
membucket := memblob.OpenBucket(nil)
filefs := afero.NewBasePathFs(afero.NewOsFs(), tmpfsdir)
filebucket, err := fileblob.OpenBucket(tmpbucketdir, nil)
if err != nil {
return nil, nil, err
}
tests := []*fsTest{
{"mem", memfs, membucket},
{"file", filefs, filebucket},
}
cleanup := func() {
membucket.Close()
filebucket.Close()
os.RemoveAll(tmpfsdir)
os.RemoveAll(tmpbucketdir)
}
return tests, cleanup, nil
}
// TestEndToEndSync verifies that basic adds, updates, and deletes are working
// correctly.
func TestEndToEndSync(t *testing.T) {
ctx := context.Background()
tests, cleanup, err := initFsTests()
if err != nil {
t.Fatal(err)
}
defer cleanup()
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
local, err := initLocalFs(ctx, test.fs)
if err != nil {
t.Fatal(err)
}
deployer := &Deployer{
localFs: test.fs,
maxDeletes: -1,
bucket: test.bucket,
mediaTypes: media.DefaultTypes,
}
// Initial deployment should sync remote with local.
if err := deployer.Deploy(ctx); err != nil {
t.Errorf("initial deploy: failed: %v", err)
}
wantSummary := deploySummary{NumLocal: 5, NumRemote: 0, NumUploads: 5, NumDeletes: 0}
if !cmp.Equal(deployer.summary, wantSummary) {
t.Errorf("initial deploy: got %v, want %v", deployer.summary, wantSummary)
}
if diff, err := verifyRemote(ctx, deployer.bucket, local); err != nil {
t.Errorf("initial deploy: failed to verify remote: %v", err)
} else if diff != "" {
t.Errorf("initial deploy: remote snapshot doesn't match expected:\n%v", diff)
}
// A repeat deployment shouldn't change anything.
if err := deployer.Deploy(ctx); err != nil {
t.Errorf("no-op deploy: %v", err)
}
wantSummary = deploySummary{NumLocal: 5, NumRemote: 5, NumUploads: 0, NumDeletes: 0}
if !cmp.Equal(deployer.summary, wantSummary) {
t.Errorf("no-op deploy: got %v, want %v", deployer.summary, wantSummary)
}
// Make some changes to the local filesystem:
// 1. Modify file [0].
// 2. Delete file [1].
// 3. Add a new file (sorted last).
updatefd := local[0]
updatefd.Contents = "new contents"
deletefd := local[1]
local = append(local[:1], local[2:]...) // removing deleted [1]
newfd := &fileData{"zzz", "zzz"}
local = append(local, newfd)
if err := writeFiles(test.fs, []*fileData{updatefd, newfd}); err != nil {
t.Fatal(err)
}
if err := test.fs.Remove(deletefd.Name); err != nil {
t.Fatal(err)
}
// A deployment should apply those 3 changes.
if err := deployer.Deploy(ctx); err != nil {
t.Errorf("deploy after changes: failed: %v", err)
}
wantSummary = deploySummary{NumLocal: 5, NumRemote: 5, NumUploads: 2, NumDeletes: 1}
if !cmp.Equal(deployer.summary, wantSummary) {
t.Errorf("deploy after changes: got %v, want %v", deployer.summary, wantSummary)
}
if diff, err := verifyRemote(ctx, deployer.bucket, local); err != nil {
t.Errorf("deploy after changes: failed to verify remote: %v", err)
} else if diff != "" {
t.Errorf("deploy after changes: remote snapshot doesn't match expected:\n%v", diff)
}
// Again, a repeat deployment shouldn't change anything.
if err := deployer.Deploy(ctx); err != nil {
t.Errorf("no-op deploy: %v", err)
}
wantSummary = deploySummary{NumLocal: 5, NumRemote: 5, NumUploads: 0, NumDeletes: 0}
if !cmp.Equal(deployer.summary, wantSummary) {
t.Errorf("no-op deploy: got %v, want %v", deployer.summary, wantSummary)
}
})
}
}
// TestMaxDeletes verifies that the "maxDeletes" flag is working correctly.
func TestMaxDeletes(t *testing.T) {
ctx := context.Background()
tests, cleanup, err := initFsTests()
if err != nil {
t.Fatal(err)
}
defer cleanup()
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
local, err := initLocalFs(ctx, test.fs)
if err != nil {
t.Fatal(err)
}
deployer := &Deployer{
localFs: test.fs,
maxDeletes: -1,
bucket: test.bucket,
mediaTypes: media.DefaultTypes,
}
// Sync remote with local.
if err := deployer.Deploy(ctx); err != nil {
t.Errorf("initial deploy: failed: %v", err)
}
wantSummary := deploySummary{NumLocal: 5, NumRemote: 0, NumUploads: 5, NumDeletes: 0}
if !cmp.Equal(deployer.summary, wantSummary) {
t.Errorf("initial deploy: got %v, want %v", deployer.summary, wantSummary)
}
// Delete two files, [1] and [2].
if err := test.fs.Remove(local[1].Name); err != nil {
t.Fatal(err)
}
if err := test.fs.Remove(local[2].Name); err != nil {
t.Fatal(err)
}
// A deployment with maxDeletes=0 shouldn't change anything.
deployer.maxDeletes = 0
if err := deployer.Deploy(ctx); err != nil {
t.Errorf("deploy failed: %v", err)
}
wantSummary = deploySummary{NumLocal: 3, NumRemote: 5, NumUploads: 0, NumDeletes: 0}
if !cmp.Equal(deployer.summary, wantSummary) {
t.Errorf("deploy: got %v, want %v", deployer.summary, wantSummary)
}
// A deployment with maxDeletes=1 shouldn't change anything either.
deployer.maxDeletes = 1
if err := deployer.Deploy(ctx); err != nil {
t.Errorf("deploy failed: %v", err)
}
wantSummary = deploySummary{NumLocal: 3, NumRemote: 5, NumUploads: 0, NumDeletes: 0}
if !cmp.Equal(deployer.summary, wantSummary) {
t.Errorf("deploy: got %v, want %v", deployer.summary, wantSummary)
}
// A deployment with maxDeletes=2 should make the changes.
deployer.maxDeletes = 2
if err := deployer.Deploy(ctx); err != nil {
t.Errorf("deploy failed: %v", err)
}
wantSummary = deploySummary{NumLocal: 3, NumRemote: 5, NumUploads: 0, NumDeletes: 2}
if !cmp.Equal(deployer.summary, wantSummary) {
t.Errorf("deploy: got %v, want %v", deployer.summary, wantSummary)
}
// Delete two more files, [0] and [3].
if err := test.fs.Remove(local[0].Name); err != nil {
t.Fatal(err)
}
if err := test.fs.Remove(local[3].Name); err != nil {
t.Fatal(err)
}
// A deployment with maxDeletes=-1 should make the changes.
deployer.maxDeletes = -1
if err := deployer.Deploy(ctx); err != nil {
t.Errorf("deploy failed: %v", err)
}
wantSummary = deploySummary{NumLocal: 1, NumRemote: 3, NumUploads: 0, NumDeletes: 2}
if !cmp.Equal(deployer.summary, wantSummary) {
t.Errorf("deploy: got %v, want %v", deployer.summary, wantSummary)
}
})
}
}
// TestIncludeExclude verifies that the include/exclude options for targets work.
func TestIncludeExclude(t *testing.T) {
ctx := context.Background()
tests := []struct {
Include string
Exclude string
Want deploySummary
}{
{
Want: deploySummary{NumLocal: 5, NumUploads: 5},
},
{
Include: "**aaa",
Want: deploySummary{NumLocal: 3, NumUploads: 3},
},
{
Include: "**bbb",
Want: deploySummary{NumLocal: 2, NumUploads: 2},
},
{
Include: "aaa",
Want: deploySummary{NumLocal: 1, NumUploads: 1},
},
{
Exclude: "**aaa",
Want: deploySummary{NumLocal: 2, NumUploads: 2},
},
{
Exclude: "**bbb",
Want: deploySummary{NumLocal: 3, NumUploads: 3},
},
{
Exclude: "aaa",
Want: deploySummary{NumLocal: 4, NumUploads: 4},
},
{
Include: "**aaa",
Exclude: "**nested**",
Want: deploySummary{NumLocal: 2, NumUploads: 2},
},
}
for _, test := range tests {
t.Run(fmt.Sprintf("include %q exclude %q", test.Include, test.Exclude), func(t *testing.T) {
fsTests, cleanup, err := initFsTests()
if err != nil {
t.Fatal(err)
}
defer cleanup()
fsTest := fsTests[1] // just do file-based test
_, err = initLocalFs(ctx, fsTest.fs)
if err != nil {
t.Fatal(err)
}
tgt := &target{
Include: test.Include,
Exclude: test.Exclude,
}
if err := tgt.parseIncludeExclude(); err != nil {
t.Error(err)
}
deployer := &Deployer{
localFs: fsTest.fs,
maxDeletes: -1,
bucket: fsTest.bucket,
target: tgt,
mediaTypes: media.DefaultTypes,
}
// Sync remote with local.
if err := deployer.Deploy(ctx); err != nil {
t.Errorf("deploy: failed: %v", err)
}
if !cmp.Equal(deployer.summary, test.Want) {
t.Errorf("deploy: got %v, want %v", deployer.summary, test.Want)
}
})
}
}
// TestIncludeExcludeRemoteDelete verifies deleted local files that don't match include/exclude patterns
// are not deleted on the remote.
func TestIncludeExcludeRemoteDelete(t *testing.T) {
ctx := context.Background()
tests := []struct {
Include string
Exclude string
Want deploySummary
}{
{
Want: deploySummary{NumLocal: 3, NumRemote: 5, NumUploads: 0, NumDeletes: 2},
},
{
Include: "**aaa",
Want: deploySummary{NumLocal: 2, NumRemote: 3, NumUploads: 0, NumDeletes: 1},
},
{
Include: "subdir/**",
Want: deploySummary{NumLocal: 1, NumRemote: 2, NumUploads: 0, NumDeletes: 1},
},
{
Exclude: "**bbb",
Want: deploySummary{NumLocal: 2, NumRemote: 3, NumUploads: 0, NumDeletes: 1},
},
{
Exclude: "bbb",
Want: deploySummary{NumLocal: 3, NumRemote: 4, NumUploads: 0, NumDeletes: 1},
},
}
for _, test := range tests {
t.Run(fmt.Sprintf("include %q exclude %q", test.Include, test.Exclude), func(t *testing.T) {
fsTests, cleanup, err := initFsTests()
if err != nil {
t.Fatal(err)
}
defer cleanup()
fsTest := fsTests[1] // just do file-based test
local, err := initLocalFs(ctx, fsTest.fs)
if err != nil {
t.Fatal(err)
}
deployer := &Deployer{
localFs: fsTest.fs,
maxDeletes: -1,
bucket: fsTest.bucket,
mediaTypes: media.DefaultTypes,
}
// Initial sync to get the files on the remote
if err := deployer.Deploy(ctx); err != nil {
t.Errorf("deploy: failed: %v", err)
}
// Delete two files, [1] and [2].
if err := fsTest.fs.Remove(local[1].Name); err != nil {
t.Fatal(err)
}
if err := fsTest.fs.Remove(local[2].Name); err != nil {
t.Fatal(err)
}
// Second sync
tgt := &target{
Include: test.Include,
Exclude: test.Exclude,
}
if err := tgt.parseIncludeExclude(); err != nil {
t.Error(err)
}
deployer.target = tgt
if err := deployer.Deploy(ctx); err != nil {
t.Errorf("deploy: failed: %v", err)
}
if !cmp.Equal(deployer.summary, test.Want) {
t.Errorf("deploy: got %v, want %v", deployer.summary, test.Want)
}
})
}
}
// TestCompression verifies that gzip compression works correctly.
// In particular, MD5 hashes must be of the compressed content.
func TestCompression(t *testing.T) {
ctx := context.Background()
tests, cleanup, err := initFsTests()
if err != nil {
t.Fatal(err)
}
defer cleanup()
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
local, err := initLocalFs(ctx, test.fs)
if err != nil {
t.Fatal(err)
}
deployer := &Deployer{
localFs: test.fs,
bucket: test.bucket,
matchers: []*matcher{{Pattern: ".*", Gzip: true, re: regexp.MustCompile(".*")}},
mediaTypes: media.DefaultTypes,
}
// Initial deployment should sync remote with local.
if err := deployer.Deploy(ctx); err != nil {
t.Errorf("initial deploy: failed: %v", err)
}
wantSummary := deploySummary{NumLocal: 5, NumRemote: 0, NumUploads: 5, NumDeletes: 0}
if !cmp.Equal(deployer.summary, wantSummary) {
t.Errorf("initial deploy: got %v, want %v", deployer.summary, wantSummary)
}
// A repeat deployment shouldn't change anything.
if err := deployer.Deploy(ctx); err != nil {
t.Errorf("no-op deploy: %v", err)
}
wantSummary = deploySummary{NumLocal: 5, NumRemote: 5, NumUploads: 0, NumDeletes: 0}
if !cmp.Equal(deployer.summary, wantSummary) {
t.Errorf("no-op deploy: got %v, want %v", deployer.summary, wantSummary)
}
// Make an update to the local filesystem, on [1].
updatefd := local[1]
updatefd.Contents = "new contents"
if err := writeFiles(test.fs, []*fileData{updatefd}); err != nil {
t.Fatal(err)
}
// A deployment should apply the changes.
if err := deployer.Deploy(ctx); err != nil {
t.Errorf("deploy after changes: failed: %v", err)
}
wantSummary = deploySummary{NumLocal: 5, NumRemote: 5, NumUploads: 1, NumDeletes: 0}
if !cmp.Equal(deployer.summary, wantSummary) {
t.Errorf("deploy after changes: got %v, want %v", deployer.summary, wantSummary)
}
})
}
}
// TestMatching verifies that matchers match correctly, and that the Force
// attribute for matcher works.
func TestMatching(t *testing.T) {
ctx := context.Background()
tests, cleanup, err := initFsTests()
if err != nil {
t.Fatal(err)
}
defer cleanup()
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
_, err := initLocalFs(ctx, test.fs)
if err != nil {
t.Fatal(err)
}
deployer := &Deployer{
localFs: test.fs,
bucket: test.bucket,
matchers: []*matcher{{Pattern: "^subdir/aaa$", Force: true, re: regexp.MustCompile("^subdir/aaa$")}},
mediaTypes: media.DefaultTypes,
}
// Initial deployment to sync remote with local.
if err := deployer.Deploy(ctx); err != nil {
t.Errorf("initial deploy: failed: %v", err)
}
wantSummary := deploySummary{NumLocal: 5, NumRemote: 0, NumUploads: 5, NumDeletes: 0}
if !cmp.Equal(deployer.summary, wantSummary) {
t.Errorf("initial deploy: got %v, want %v", deployer.summary, wantSummary)
}
// A repeat deployment should upload a single file, the one that matched the Force matcher.
// Note that matching happens based on the ToSlash form, so this matches
// even on Windows.
if err := deployer.Deploy(ctx); err != nil {
t.Errorf("no-op deploy with single force matcher: %v", err)
}
wantSummary = deploySummary{NumLocal: 5, NumRemote: 5, NumUploads: 1, NumDeletes: 0}
if !cmp.Equal(deployer.summary, wantSummary) {
t.Errorf("no-op deploy with single force matcher: got %v, want %v", deployer.summary, wantSummary)
}
// Repeat with a matcher that should now match 3 files.
deployer.matchers = []*matcher{{Pattern: "aaa", Force: true, re: regexp.MustCompile("aaa")}}
if err := deployer.Deploy(ctx); err != nil {
t.Errorf("no-op deploy with triple force matcher: %v", err)
}
wantSummary = deploySummary{NumLocal: 5, NumRemote: 5, NumUploads: 3, NumDeletes: 0}
if !cmp.Equal(deployer.summary, wantSummary) {
t.Errorf("no-op deploy with triple force matcher: got %v, want %v", deployer.summary, wantSummary)
}
})
}
}
// writeFiles writes the files in fds to fd.
func writeFiles(fs afero.Fs, fds []*fileData) error {
for _, fd := range fds {
dir := path.Dir(fd.Name)
if dir != "." {
err := fs.MkdirAll(dir, os.ModePerm)
if err != nil {
return err
}
}
f, err := fs.Create(fd.Name)
if err != nil {
return err
}
defer f.Close()
_, err = f.WriteString(fd.Contents)
if err != nil {
return err
}
}
return nil
}
// verifyRemote that the current contents of bucket matches local.
// It returns an empty string if the contents matched, and a non-empty string
// capturing the diff if they didn't.
func verifyRemote(ctx context.Context, bucket *blob.Bucket, local []*fileData) (string, error) {
var cur []*fileData
iter := bucket.List(nil)
for {
obj, err := iter.Next(ctx)
if err == io.EOF {
break
}
if err != nil {
return "", err
}
contents, err := bucket.ReadAll(ctx, obj.Key)
if err != nil {
return "", err
}
cur = append(cur, &fileData{obj.Key, string(contents)})
}
if cmp.Equal(cur, local) {
return "", nil
}
diff := "got: \n"
for _, f := range cur {
diff += fmt.Sprintf(" %s: %s\n", f.Name, f.Contents)
}
diff += "want: \n"
for _, f := range local {
diff += fmt.Sprintf(" %s: %s\n", f.Name, f.Contents)
}
return diff, nil
}
| // Copyright 2019 The Hugo Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// +build !nodeploy
package deploy
import (
"bytes"
"compress/gzip"
"context"
"crypto/md5"
"fmt"
"io"
"io/ioutil"
"os"
"path"
"path/filepath"
"regexp"
"sort"
"testing"
"github.com/gohugoio/hugo/media"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/spf13/afero"
"gocloud.dev/blob"
"gocloud.dev/blob/fileblob"
"gocloud.dev/blob/memblob"
)
func TestFindDiffs(t *testing.T) {
hash1 := []byte("hash 1")
hash2 := []byte("hash 2")
makeLocal := func(path string, size int64, hash []byte) *localFile {
return &localFile{NativePath: path, SlashPath: filepath.ToSlash(path), UploadSize: size, md5: hash}
}
makeRemote := func(path string, size int64, hash []byte) *blob.ListObject {
return &blob.ListObject{Key: path, Size: size, MD5: hash}
}
tests := []struct {
Description string
Local []*localFile
Remote []*blob.ListObject
Force bool
WantUpdates []*fileToUpload
WantDeletes []string
}{
{
Description: "empty -> no diffs",
},
{
Description: "local == remote -> no diffs",
Local: []*localFile{
makeLocal("aaa", 1, hash1),
makeLocal("bbb", 2, hash1),
makeLocal("ccc", 3, hash2),
},
Remote: []*blob.ListObject{
makeRemote("aaa", 1, hash1),
makeRemote("bbb", 2, hash1),
makeRemote("ccc", 3, hash2),
},
},
{
Description: "local w/ separators == remote -> no diffs",
Local: []*localFile{
makeLocal(filepath.Join("aaa", "aaa"), 1, hash1),
makeLocal(filepath.Join("bbb", "bbb"), 2, hash1),
makeLocal(filepath.Join("ccc", "ccc"), 3, hash2),
},
Remote: []*blob.ListObject{
makeRemote("aaa/aaa", 1, hash1),
makeRemote("bbb/bbb", 2, hash1),
makeRemote("ccc/ccc", 3, hash2),
},
},
{
Description: "local == remote with force flag true -> diffs",
Local: []*localFile{
makeLocal("aaa", 1, hash1),
makeLocal("bbb", 2, hash1),
makeLocal("ccc", 3, hash2),
},
Remote: []*blob.ListObject{
makeRemote("aaa", 1, hash1),
makeRemote("bbb", 2, hash1),
makeRemote("ccc", 3, hash2),
},
Force: true,
WantUpdates: []*fileToUpload{
{makeLocal("aaa", 1, nil), reasonForce},
{makeLocal("bbb", 2, nil), reasonForce},
{makeLocal("ccc", 3, nil), reasonForce},
},
},
{
Description: "local == remote with route.Force true -> diffs",
Local: []*localFile{
{NativePath: "aaa", SlashPath: "aaa", UploadSize: 1, matcher: &matcher{Force: true}, md5: hash1},
makeLocal("bbb", 2, hash1),
},
Remote: []*blob.ListObject{
makeRemote("aaa", 1, hash1),
makeRemote("bbb", 2, hash1),
},
WantUpdates: []*fileToUpload{
{makeLocal("aaa", 1, nil), reasonForce},
},
},
{
Description: "extra local file -> upload",
Local: []*localFile{
makeLocal("aaa", 1, hash1),
makeLocal("bbb", 2, hash2),
},
Remote: []*blob.ListObject{
makeRemote("aaa", 1, hash1),
},
WantUpdates: []*fileToUpload{
{makeLocal("bbb", 2, nil), reasonNotFound},
},
},
{
Description: "extra remote file -> delete",
Local: []*localFile{
makeLocal("aaa", 1, hash1),
},
Remote: []*blob.ListObject{
makeRemote("aaa", 1, hash1),
makeRemote("bbb", 2, hash2),
},
WantDeletes: []string{"bbb"},
},
{
Description: "diffs in size or md5 -> upload",
Local: []*localFile{
makeLocal("aaa", 1, hash1),
makeLocal("bbb", 2, hash1),
makeLocal("ccc", 1, hash2),
},
Remote: []*blob.ListObject{
makeRemote("aaa", 1, nil),
makeRemote("bbb", 1, hash1),
makeRemote("ccc", 1, hash1),
},
WantUpdates: []*fileToUpload{
{makeLocal("aaa", 1, nil), reasonMD5Missing},
{makeLocal("bbb", 2, nil), reasonSize},
{makeLocal("ccc", 1, nil), reasonMD5Differs},
},
},
{
Description: "mix of updates and deletes",
Local: []*localFile{
makeLocal("same", 1, hash1),
makeLocal("updated", 2, hash1),
makeLocal("updated2", 1, hash2),
makeLocal("new", 1, hash1),
makeLocal("new2", 2, hash2),
},
Remote: []*blob.ListObject{
makeRemote("same", 1, hash1),
makeRemote("updated", 1, hash1),
makeRemote("updated2", 1, hash1),
makeRemote("stale", 1, hash1),
makeRemote("stale2", 1, hash1),
},
WantUpdates: []*fileToUpload{
{makeLocal("new", 1, nil), reasonNotFound},
{makeLocal("new2", 2, nil), reasonNotFound},
{makeLocal("updated", 2, nil), reasonSize},
{makeLocal("updated2", 1, nil), reasonMD5Differs},
},
WantDeletes: []string{"stale", "stale2"},
},
}
for _, tc := range tests {
t.Run(tc.Description, func(t *testing.T) {
local := map[string]*localFile{}
for _, l := range tc.Local {
local[l.SlashPath] = l
}
remote := map[string]*blob.ListObject{}
for _, r := range tc.Remote {
remote[r.Key] = r
}
gotUpdates, gotDeletes := findDiffs(local, remote, tc.Force)
gotUpdates = applyOrdering(nil, gotUpdates)[0]
sort.Slice(gotDeletes, func(i, j int) bool { return gotDeletes[i] < gotDeletes[j] })
if diff := cmp.Diff(gotUpdates, tc.WantUpdates, cmpopts.IgnoreUnexported(localFile{})); diff != "" {
t.Errorf("updates differ:\n%s", diff)
}
if diff := cmp.Diff(gotDeletes, tc.WantDeletes); diff != "" {
t.Errorf("deletes differ:\n%s", diff)
}
})
}
}
func TestWalkLocal(t *testing.T) {
tests := map[string]struct {
Given []string
Expect []string
}{
"Empty": {
Given: []string{},
Expect: []string{},
},
"Normal": {
Given: []string{"file.txt", "normal_dir/file.txt"},
Expect: []string{"file.txt", "normal_dir/file.txt"},
},
"Hidden": {
Given: []string{"file.txt", ".hidden_dir/file.txt", "normal_dir/file.txt"},
Expect: []string{"file.txt", "normal_dir/file.txt"},
},
"Well Known": {
Given: []string{"file.txt", ".hidden_dir/file.txt", ".well-known/file.txt"},
Expect: []string{"file.txt", ".well-known/file.txt"},
},
}
for desc, tc := range tests {
t.Run(desc, func(t *testing.T) {
fs := afero.NewMemMapFs()
for _, name := range tc.Given {
dir, _ := path.Split(name)
if dir != "" {
if err := fs.MkdirAll(dir, 0755); err != nil {
t.Fatal(err)
}
}
if fd, err := fs.Create(name); err != nil {
t.Fatal(err)
} else {
fd.Close()
}
}
if got, err := walkLocal(fs, nil, nil, nil, media.DefaultTypes); err != nil {
t.Fatal(err)
} else {
expect := map[string]interface{}{}
for _, path := range tc.Expect {
if _, ok := got[path]; !ok {
t.Errorf("expected %q in results, but was not found", path)
}
expect[path] = nil
}
for path := range got {
if _, ok := expect[path]; !ok {
t.Errorf("got %q in results unexpectedly", path)
}
}
}
})
}
}
func TestLocalFile(t *testing.T) {
const (
content = "hello world!"
)
contentBytes := []byte(content)
contentLen := int64(len(contentBytes))
contentMD5 := md5.Sum(contentBytes)
var buf bytes.Buffer
gz := gzip.NewWriter(&buf)
if _, err := gz.Write(contentBytes); err != nil {
t.Fatal(err)
}
gz.Close()
gzBytes := buf.Bytes()
gzLen := int64(len(gzBytes))
gzMD5 := md5.Sum(gzBytes)
tests := []struct {
Description string
Path string
Matcher *matcher
MediaTypesConfig []map[string]interface{}
WantContent []byte
WantSize int64
WantMD5 []byte
WantContentType string // empty string is always OK, since content type detection is OS-specific
WantCacheControl string
WantContentEncoding string
}{
{
Description: "file with no suffix",
Path: "foo",
WantContent: contentBytes,
WantSize: contentLen,
WantMD5: contentMD5[:],
},
{
Description: "file with .txt suffix",
Path: "foo.txt",
WantContent: contentBytes,
WantSize: contentLen,
WantMD5: contentMD5[:],
},
{
Description: "CacheControl from matcher",
Path: "foo.txt",
Matcher: &matcher{CacheControl: "max-age=630720000"},
WantContent: contentBytes,
WantSize: contentLen,
WantMD5: contentMD5[:],
WantCacheControl: "max-age=630720000",
},
{
Description: "ContentEncoding from matcher",
Path: "foo.txt",
Matcher: &matcher{ContentEncoding: "foobar"},
WantContent: contentBytes,
WantSize: contentLen,
WantMD5: contentMD5[:],
WantContentEncoding: "foobar",
},
{
Description: "ContentType from matcher",
Path: "foo.txt",
Matcher: &matcher{ContentType: "foo/bar"},
WantContent: contentBytes,
WantSize: contentLen,
WantMD5: contentMD5[:],
WantContentType: "foo/bar",
},
{
Description: "gzipped content",
Path: "foo.txt",
Matcher: &matcher{Gzip: true},
WantContent: gzBytes,
WantSize: gzLen,
WantMD5: gzMD5[:],
WantContentEncoding: "gzip",
},
{
Description: "Custom MediaType",
Path: "foo.hugo",
MediaTypesConfig: []map[string]interface{}{
{
"hugo/custom": map[string]interface{}{
"suffixes": []string{"hugo"},
},
},
},
WantContent: contentBytes,
WantSize: contentLen,
WantMD5: contentMD5[:],
WantContentType: "hugo/custom",
},
}
for _, tc := range tests {
t.Run(tc.Description, func(t *testing.T) {
fs := new(afero.MemMapFs)
if err := afero.WriteFile(fs, tc.Path, []byte(content), os.ModePerm); err != nil {
t.Fatal(err)
}
mediaTypes := media.DefaultTypes
if len(tc.MediaTypesConfig) > 0 {
mt, err := media.DecodeTypes(tc.MediaTypesConfig...)
if err != nil {
t.Fatal(err)
}
mediaTypes = mt
}
lf, err := newLocalFile(fs, tc.Path, filepath.ToSlash(tc.Path), tc.Matcher, mediaTypes)
if err != nil {
t.Fatal(err)
}
if got := lf.UploadSize; got != tc.WantSize {
t.Errorf("got size %d want %d", got, tc.WantSize)
}
if got := lf.MD5(); !bytes.Equal(got, tc.WantMD5) {
t.Errorf("got MD5 %x want %x", got, tc.WantMD5)
}
if got := lf.CacheControl(); got != tc.WantCacheControl {
t.Errorf("got CacheControl %q want %q", got, tc.WantCacheControl)
}
if got := lf.ContentEncoding(); got != tc.WantContentEncoding {
t.Errorf("got ContentEncoding %q want %q", got, tc.WantContentEncoding)
}
if tc.WantContentType != "" {
if got := lf.ContentType(); got != tc.WantContentType {
t.Errorf("got ContentType %q want %q", got, tc.WantContentType)
}
}
// Verify the reader last to ensure the previous operations don't
// interfere with it.
r, err := lf.Reader()
if err != nil {
t.Fatal(err)
}
gotContent, err := ioutil.ReadAll(r)
if err != nil {
t.Fatal(err)
}
if !bytes.Equal(gotContent, tc.WantContent) {
t.Errorf("got content %q want %q", string(gotContent), string(tc.WantContent))
}
r.Close()
// Verify we can read again.
r, err = lf.Reader()
if err != nil {
t.Fatal(err)
}
gotContent, err = ioutil.ReadAll(r)
if err != nil {
t.Fatal(err)
}
r.Close()
if !bytes.Equal(gotContent, tc.WantContent) {
t.Errorf("got content %q want %q", string(gotContent), string(tc.WantContent))
}
})
}
}
func TestOrdering(t *testing.T) {
tests := []struct {
Description string
Uploads []string
Ordering []*regexp.Regexp
Want [][]string
}{
{
Description: "empty",
Want: [][]string{nil},
},
{
Description: "no ordering",
Uploads: []string{"c", "b", "a", "d"},
Want: [][]string{{"a", "b", "c", "d"}},
},
{
Description: "one ordering",
Uploads: []string{"db", "c", "b", "a", "da"},
Ordering: []*regexp.Regexp{regexp.MustCompile("^d")},
Want: [][]string{{"da", "db"}, {"a", "b", "c"}},
},
{
Description: "two orderings",
Uploads: []string{"db", "c", "b", "a", "da"},
Ordering: []*regexp.Regexp{
regexp.MustCompile("^d"),
regexp.MustCompile("^b"),
},
Want: [][]string{{"da", "db"}, {"b"}, {"a", "c"}},
},
}
for _, tc := range tests {
t.Run(tc.Description, func(t *testing.T) {
uploads := make([]*fileToUpload, len(tc.Uploads))
for i, u := range tc.Uploads {
uploads[i] = &fileToUpload{Local: &localFile{SlashPath: u}}
}
gotUploads := applyOrdering(tc.Ordering, uploads)
var got [][]string
for _, subslice := range gotUploads {
var gotsubslice []string
for _, u := range subslice {
gotsubslice = append(gotsubslice, u.Local.SlashPath)
}
got = append(got, gotsubslice)
}
if diff := cmp.Diff(got, tc.Want); diff != "" {
t.Error(diff)
}
})
}
}
type fileData struct {
Name string // name of the file
Contents string // contents of the file
}
// initLocalFs initializes fs with some test files.
func initLocalFs(ctx context.Context, fs afero.Fs) ([]*fileData, error) {
// The initial local filesystem.
local := []*fileData{
{"aaa", "aaa"},
{"bbb", "bbb"},
{"subdir/aaa", "subdir-aaa"},
{"subdir/nested/aaa", "subdir-nested-aaa"},
{"subdir2/bbb", "subdir2-bbb"},
}
if err := writeFiles(fs, local); err != nil {
return nil, err
}
return local, nil
}
// fsTest represents an (afero.FS, Go CDK blob.Bucket) against which end-to-end
// tests can be run.
type fsTest struct {
name string
fs afero.Fs
bucket *blob.Bucket
}
// initFsTests initializes a pair of tests for end-to-end test:
// 1. An in-memory afero.Fs paired with an in-memory Go CDK bucket.
// 2. A filesystem-based afero.Fs paired with an filesystem-based Go CDK bucket.
// It returns the pair of tests and a cleanup function.
func initFsTests() ([]*fsTest, func(), error) {
tmpfsdir, err := ioutil.TempDir("", "fs")
if err != nil {
return nil, nil, err
}
tmpbucketdir, err := ioutil.TempDir("", "bucket")
if err != nil {
return nil, nil, err
}
memfs := afero.NewMemMapFs()
membucket := memblob.OpenBucket(nil)
filefs := afero.NewBasePathFs(afero.NewOsFs(), tmpfsdir)
filebucket, err := fileblob.OpenBucket(tmpbucketdir, nil)
if err != nil {
return nil, nil, err
}
tests := []*fsTest{
{"mem", memfs, membucket},
{"file", filefs, filebucket},
}
cleanup := func() {
membucket.Close()
filebucket.Close()
os.RemoveAll(tmpfsdir)
os.RemoveAll(tmpbucketdir)
}
return tests, cleanup, nil
}
// TestEndToEndSync verifies that basic adds, updates, and deletes are working
// correctly.
func TestEndToEndSync(t *testing.T) {
ctx := context.Background()
tests, cleanup, err := initFsTests()
if err != nil {
t.Fatal(err)
}
defer cleanup()
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
local, err := initLocalFs(ctx, test.fs)
if err != nil {
t.Fatal(err)
}
deployer := &Deployer{
localFs: test.fs,
maxDeletes: -1,
bucket: test.bucket,
mediaTypes: media.DefaultTypes,
}
// Initial deployment should sync remote with local.
if err := deployer.Deploy(ctx); err != nil {
t.Errorf("initial deploy: failed: %v", err)
}
wantSummary := deploySummary{NumLocal: 5, NumRemote: 0, NumUploads: 5, NumDeletes: 0}
if !cmp.Equal(deployer.summary, wantSummary) {
t.Errorf("initial deploy: got %v, want %v", deployer.summary, wantSummary)
}
if diff, err := verifyRemote(ctx, deployer.bucket, local); err != nil {
t.Errorf("initial deploy: failed to verify remote: %v", err)
} else if diff != "" {
t.Errorf("initial deploy: remote snapshot doesn't match expected:\n%v", diff)
}
// A repeat deployment shouldn't change anything.
if err := deployer.Deploy(ctx); err != nil {
t.Errorf("no-op deploy: %v", err)
}
wantSummary = deploySummary{NumLocal: 5, NumRemote: 5, NumUploads: 0, NumDeletes: 0}
if !cmp.Equal(deployer.summary, wantSummary) {
t.Errorf("no-op deploy: got %v, want %v", deployer.summary, wantSummary)
}
// Make some changes to the local filesystem:
// 1. Modify file [0].
// 2. Delete file [1].
// 3. Add a new file (sorted last).
updatefd := local[0]
updatefd.Contents = "new contents"
deletefd := local[1]
local = append(local[:1], local[2:]...) // removing deleted [1]
newfd := &fileData{"zzz", "zzz"}
local = append(local, newfd)
if err := writeFiles(test.fs, []*fileData{updatefd, newfd}); err != nil {
t.Fatal(err)
}
if err := test.fs.Remove(deletefd.Name); err != nil {
t.Fatal(err)
}
// A deployment should apply those 3 changes.
if err := deployer.Deploy(ctx); err != nil {
t.Errorf("deploy after changes: failed: %v", err)
}
wantSummary = deploySummary{NumLocal: 5, NumRemote: 5, NumUploads: 2, NumDeletes: 1}
if !cmp.Equal(deployer.summary, wantSummary) {
t.Errorf("deploy after changes: got %v, want %v", deployer.summary, wantSummary)
}
if diff, err := verifyRemote(ctx, deployer.bucket, local); err != nil {
t.Errorf("deploy after changes: failed to verify remote: %v", err)
} else if diff != "" {
t.Errorf("deploy after changes: remote snapshot doesn't match expected:\n%v", diff)
}
// Again, a repeat deployment shouldn't change anything.
if err := deployer.Deploy(ctx); err != nil {
t.Errorf("no-op deploy: %v", err)
}
wantSummary = deploySummary{NumLocal: 5, NumRemote: 5, NumUploads: 0, NumDeletes: 0}
if !cmp.Equal(deployer.summary, wantSummary) {
t.Errorf("no-op deploy: got %v, want %v", deployer.summary, wantSummary)
}
})
}
}
// TestMaxDeletes verifies that the "maxDeletes" flag is working correctly.
func TestMaxDeletes(t *testing.T) {
ctx := context.Background()
tests, cleanup, err := initFsTests()
if err != nil {
t.Fatal(err)
}
defer cleanup()
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
local, err := initLocalFs(ctx, test.fs)
if err != nil {
t.Fatal(err)
}
deployer := &Deployer{
localFs: test.fs,
maxDeletes: -1,
bucket: test.bucket,
mediaTypes: media.DefaultTypes,
}
// Sync remote with local.
if err := deployer.Deploy(ctx); err != nil {
t.Errorf("initial deploy: failed: %v", err)
}
wantSummary := deploySummary{NumLocal: 5, NumRemote: 0, NumUploads: 5, NumDeletes: 0}
if !cmp.Equal(deployer.summary, wantSummary) {
t.Errorf("initial deploy: got %v, want %v", deployer.summary, wantSummary)
}
// Delete two files, [1] and [2].
if err := test.fs.Remove(local[1].Name); err != nil {
t.Fatal(err)
}
if err := test.fs.Remove(local[2].Name); err != nil {
t.Fatal(err)
}
// A deployment with maxDeletes=0 shouldn't change anything.
deployer.maxDeletes = 0
if err := deployer.Deploy(ctx); err != nil {
t.Errorf("deploy failed: %v", err)
}
wantSummary = deploySummary{NumLocal: 3, NumRemote: 5, NumUploads: 0, NumDeletes: 0}
if !cmp.Equal(deployer.summary, wantSummary) {
t.Errorf("deploy: got %v, want %v", deployer.summary, wantSummary)
}
// A deployment with maxDeletes=1 shouldn't change anything either.
deployer.maxDeletes = 1
if err := deployer.Deploy(ctx); err != nil {
t.Errorf("deploy failed: %v", err)
}
wantSummary = deploySummary{NumLocal: 3, NumRemote: 5, NumUploads: 0, NumDeletes: 0}
if !cmp.Equal(deployer.summary, wantSummary) {
t.Errorf("deploy: got %v, want %v", deployer.summary, wantSummary)
}
// A deployment with maxDeletes=2 should make the changes.
deployer.maxDeletes = 2
if err := deployer.Deploy(ctx); err != nil {
t.Errorf("deploy failed: %v", err)
}
wantSummary = deploySummary{NumLocal: 3, NumRemote: 5, NumUploads: 0, NumDeletes: 2}
if !cmp.Equal(deployer.summary, wantSummary) {
t.Errorf("deploy: got %v, want %v", deployer.summary, wantSummary)
}
// Delete two more files, [0] and [3].
if err := test.fs.Remove(local[0].Name); err != nil {
t.Fatal(err)
}
if err := test.fs.Remove(local[3].Name); err != nil {
t.Fatal(err)
}
// A deployment with maxDeletes=-1 should make the changes.
deployer.maxDeletes = -1
if err := deployer.Deploy(ctx); err != nil {
t.Errorf("deploy failed: %v", err)
}
wantSummary = deploySummary{NumLocal: 1, NumRemote: 3, NumUploads: 0, NumDeletes: 2}
if !cmp.Equal(deployer.summary, wantSummary) {
t.Errorf("deploy: got %v, want %v", deployer.summary, wantSummary)
}
})
}
}
// TestIncludeExclude verifies that the include/exclude options for targets work.
func TestIncludeExclude(t *testing.T) {
ctx := context.Background()
tests := []struct {
Include string
Exclude string
Want deploySummary
}{
{
Want: deploySummary{NumLocal: 5, NumUploads: 5},
},
{
Include: "**aaa",
Want: deploySummary{NumLocal: 3, NumUploads: 3},
},
{
Include: "**bbb",
Want: deploySummary{NumLocal: 2, NumUploads: 2},
},
{
Include: "aaa",
Want: deploySummary{NumLocal: 1, NumUploads: 1},
},
{
Exclude: "**aaa",
Want: deploySummary{NumLocal: 2, NumUploads: 2},
},
{
Exclude: "**bbb",
Want: deploySummary{NumLocal: 3, NumUploads: 3},
},
{
Exclude: "aaa",
Want: deploySummary{NumLocal: 4, NumUploads: 4},
},
{
Include: "**aaa",
Exclude: "**nested**",
Want: deploySummary{NumLocal: 2, NumUploads: 2},
},
}
for _, test := range tests {
t.Run(fmt.Sprintf("include %q exclude %q", test.Include, test.Exclude), func(t *testing.T) {
fsTests, cleanup, err := initFsTests()
if err != nil {
t.Fatal(err)
}
defer cleanup()
fsTest := fsTests[1] // just do file-based test
_, err = initLocalFs(ctx, fsTest.fs)
if err != nil {
t.Fatal(err)
}
tgt := &target{
Include: test.Include,
Exclude: test.Exclude,
}
if err := tgt.parseIncludeExclude(); err != nil {
t.Error(err)
}
deployer := &Deployer{
localFs: fsTest.fs,
maxDeletes: -1,
bucket: fsTest.bucket,
target: tgt,
mediaTypes: media.DefaultTypes,
}
// Sync remote with local.
if err := deployer.Deploy(ctx); err != nil {
t.Errorf("deploy: failed: %v", err)
}
if !cmp.Equal(deployer.summary, test.Want) {
t.Errorf("deploy: got %v, want %v", deployer.summary, test.Want)
}
})
}
}
// TestIncludeExcludeRemoteDelete verifies deleted local files that don't match include/exclude patterns
// are not deleted on the remote.
func TestIncludeExcludeRemoteDelete(t *testing.T) {
ctx := context.Background()
tests := []struct {
Include string
Exclude string
Want deploySummary
}{
{
Want: deploySummary{NumLocal: 3, NumRemote: 5, NumUploads: 0, NumDeletes: 2},
},
{
Include: "**aaa",
Want: deploySummary{NumLocal: 2, NumRemote: 3, NumUploads: 0, NumDeletes: 1},
},
{
Include: "subdir/**",
Want: deploySummary{NumLocal: 1, NumRemote: 2, NumUploads: 0, NumDeletes: 1},
},
{
Exclude: "**bbb",
Want: deploySummary{NumLocal: 2, NumRemote: 3, NumUploads: 0, NumDeletes: 1},
},
{
Exclude: "bbb",
Want: deploySummary{NumLocal: 3, NumRemote: 4, NumUploads: 0, NumDeletes: 1},
},
}
for _, test := range tests {
t.Run(fmt.Sprintf("include %q exclude %q", test.Include, test.Exclude), func(t *testing.T) {
fsTests, cleanup, err := initFsTests()
if err != nil {
t.Fatal(err)
}
defer cleanup()
fsTest := fsTests[1] // just do file-based test
local, err := initLocalFs(ctx, fsTest.fs)
if err != nil {
t.Fatal(err)
}
deployer := &Deployer{
localFs: fsTest.fs,
maxDeletes: -1,
bucket: fsTest.bucket,
mediaTypes: media.DefaultTypes,
}
// Initial sync to get the files on the remote
if err := deployer.Deploy(ctx); err != nil {
t.Errorf("deploy: failed: %v", err)
}
// Delete two files, [1] and [2].
if err := fsTest.fs.Remove(local[1].Name); err != nil {
t.Fatal(err)
}
if err := fsTest.fs.Remove(local[2].Name); err != nil {
t.Fatal(err)
}
// Second sync
tgt := &target{
Include: test.Include,
Exclude: test.Exclude,
}
if err := tgt.parseIncludeExclude(); err != nil {
t.Error(err)
}
deployer.target = tgt
if err := deployer.Deploy(ctx); err != nil {
t.Errorf("deploy: failed: %v", err)
}
if !cmp.Equal(deployer.summary, test.Want) {
t.Errorf("deploy: got %v, want %v", deployer.summary, test.Want)
}
})
}
}
// TestCompression verifies that gzip compression works correctly.
// In particular, MD5 hashes must be of the compressed content.
func TestCompression(t *testing.T) {
ctx := context.Background()
tests, cleanup, err := initFsTests()
if err != nil {
t.Fatal(err)
}
defer cleanup()
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
local, err := initLocalFs(ctx, test.fs)
if err != nil {
t.Fatal(err)
}
deployer := &Deployer{
localFs: test.fs,
bucket: test.bucket,
matchers: []*matcher{{Pattern: ".*", Gzip: true, re: regexp.MustCompile(".*")}},
mediaTypes: media.DefaultTypes,
}
// Initial deployment should sync remote with local.
if err := deployer.Deploy(ctx); err != nil {
t.Errorf("initial deploy: failed: %v", err)
}
wantSummary := deploySummary{NumLocal: 5, NumRemote: 0, NumUploads: 5, NumDeletes: 0}
if !cmp.Equal(deployer.summary, wantSummary) {
t.Errorf("initial deploy: got %v, want %v", deployer.summary, wantSummary)
}
// A repeat deployment shouldn't change anything.
if err := deployer.Deploy(ctx); err != nil {
t.Errorf("no-op deploy: %v", err)
}
wantSummary = deploySummary{NumLocal: 5, NumRemote: 5, NumUploads: 0, NumDeletes: 0}
if !cmp.Equal(deployer.summary, wantSummary) {
t.Errorf("no-op deploy: got %v, want %v", deployer.summary, wantSummary)
}
// Make an update to the local filesystem, on [1].
updatefd := local[1]
updatefd.Contents = "new contents"
if err := writeFiles(test.fs, []*fileData{updatefd}); err != nil {
t.Fatal(err)
}
// A deployment should apply the changes.
if err := deployer.Deploy(ctx); err != nil {
t.Errorf("deploy after changes: failed: %v", err)
}
wantSummary = deploySummary{NumLocal: 5, NumRemote: 5, NumUploads: 1, NumDeletes: 0}
if !cmp.Equal(deployer.summary, wantSummary) {
t.Errorf("deploy after changes: got %v, want %v", deployer.summary, wantSummary)
}
})
}
}
// TestMatching verifies that matchers match correctly, and that the Force
// attribute for matcher works.
func TestMatching(t *testing.T) {
ctx := context.Background()
tests, cleanup, err := initFsTests()
if err != nil {
t.Fatal(err)
}
defer cleanup()
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
_, err := initLocalFs(ctx, test.fs)
if err != nil {
t.Fatal(err)
}
deployer := &Deployer{
localFs: test.fs,
bucket: test.bucket,
matchers: []*matcher{{Pattern: "^subdir/aaa$", Force: true, re: regexp.MustCompile("^subdir/aaa$")}},
mediaTypes: media.DefaultTypes,
}
// Initial deployment to sync remote with local.
if err := deployer.Deploy(ctx); err != nil {
t.Errorf("initial deploy: failed: %v", err)
}
wantSummary := deploySummary{NumLocal: 5, NumRemote: 0, NumUploads: 5, NumDeletes: 0}
if !cmp.Equal(deployer.summary, wantSummary) {
t.Errorf("initial deploy: got %v, want %v", deployer.summary, wantSummary)
}
// A repeat deployment should upload a single file, the one that matched the Force matcher.
// Note that matching happens based on the ToSlash form, so this matches
// even on Windows.
if err := deployer.Deploy(ctx); err != nil {
t.Errorf("no-op deploy with single force matcher: %v", err)
}
wantSummary = deploySummary{NumLocal: 5, NumRemote: 5, NumUploads: 1, NumDeletes: 0}
if !cmp.Equal(deployer.summary, wantSummary) {
t.Errorf("no-op deploy with single force matcher: got %v, want %v", deployer.summary, wantSummary)
}
// Repeat with a matcher that should now match 3 files.
deployer.matchers = []*matcher{{Pattern: "aaa", Force: true, re: regexp.MustCompile("aaa")}}
if err := deployer.Deploy(ctx); err != nil {
t.Errorf("no-op deploy with triple force matcher: %v", err)
}
wantSummary = deploySummary{NumLocal: 5, NumRemote: 5, NumUploads: 3, NumDeletes: 0}
if !cmp.Equal(deployer.summary, wantSummary) {
t.Errorf("no-op deploy with triple force matcher: got %v, want %v", deployer.summary, wantSummary)
}
})
}
}
// writeFiles writes the files in fds to fd.
func writeFiles(fs afero.Fs, fds []*fileData) error {
for _, fd := range fds {
dir := path.Dir(fd.Name)
if dir != "." {
err := fs.MkdirAll(dir, os.ModePerm)
if err != nil {
return err
}
}
f, err := fs.Create(fd.Name)
if err != nil {
return err
}
defer f.Close()
_, err = f.WriteString(fd.Contents)
if err != nil {
return err
}
}
return nil
}
// verifyRemote that the current contents of bucket matches local.
// It returns an empty string if the contents matched, and a non-empty string
// capturing the diff if they didn't.
func verifyRemote(ctx context.Context, bucket *blob.Bucket, local []*fileData) (string, error) {
var cur []*fileData
iter := bucket.List(nil)
for {
obj, err := iter.Next(ctx)
if err == io.EOF {
break
}
if err != nil {
return "", err
}
contents, err := bucket.ReadAll(ctx, obj.Key)
if err != nil {
return "", err
}
cur = append(cur, &fileData{obj.Key, string(contents)})
}
if cmp.Equal(cur, local) {
return "", nil
}
diff := "got: \n"
for _, f := range cur {
diff += fmt.Sprintf(" %s: %s\n", f.Name, f.Contents)
}
diff += "want: \n"
for _, f := range local {
diff += fmt.Sprintf(" %s: %s\n", f.Name, f.Contents)
}
return diff, nil
}
| -1 |
gohugoio/hugo | 8,215 | markup/goldmark: Add attributes support for blocks (tables etc.) | Fixes #7548 | bep | "2021-02-08T09:42:41Z" | "2021-02-08T18:52:56Z" | 1b2472825664763c0b88807b0d193e73553423ec | 2681633db8d340d2dc59cf801419874d572fc704 | markup/goldmark: Add attributes support for blocks (tables etc.). Fixes #7548 | ./docs/content/en/commands/hugo_list_all.md | ---
date: 2020-09-13
title: "hugo list all"
slug: hugo_list_all
url: /commands/hugo_list_all/
---
## hugo list all
List all posts
### Synopsis
List all of the posts in your content directory, include drafts, future and expired pages.
```
hugo list all [flags]
```
### Options
```
-h, --help help for all
```
### Options inherited from parent commands
```
--config string config file (default is path/config.yaml|json|toml)
--configDir string config dir (default "config")
--debug debug output
-e, --environment string build environment
--ignoreVendor ignores any _vendor directory
--ignoreVendorPaths string ignores any _vendor for module paths matching the given Glob pattern
--log enable Logging
--logFile string log File path (if set, logging enabled automatically)
--quiet build in quiet mode
-s, --source string filesystem path to read files relative from
--themesDir string filesystem path to themes directory
-v, --verbose verbose output
--verboseLog verbose logging
```
### SEE ALSO
* [hugo list](/commands/hugo_list/) - Listing out various types of content
###### Auto generated by spf13/cobra on 13-Sep-2020
| ---
date: 2020-09-13
title: "hugo list all"
slug: hugo_list_all
url: /commands/hugo_list_all/
---
## hugo list all
List all posts
### Synopsis
List all of the posts in your content directory, include drafts, future and expired pages.
```
hugo list all [flags]
```
### Options
```
-h, --help help for all
```
### Options inherited from parent commands
```
--config string config file (default is path/config.yaml|json|toml)
--configDir string config dir (default "config")
--debug debug output
-e, --environment string build environment
--ignoreVendor ignores any _vendor directory
--ignoreVendorPaths string ignores any _vendor for module paths matching the given Glob pattern
--log enable Logging
--logFile string log File path (if set, logging enabled automatically)
--quiet build in quiet mode
-s, --source string filesystem path to read files relative from
--themesDir string filesystem path to themes directory
-v, --verbose verbose output
--verboseLog verbose logging
```
### SEE ALSO
* [hugo list](/commands/hugo_list/) - Listing out various types of content
###### Auto generated by spf13/cobra on 13-Sep-2020
| -1 |
gohugoio/hugo | 8,215 | markup/goldmark: Add attributes support for blocks (tables etc.) | Fixes #7548 | bep | "2021-02-08T09:42:41Z" | "2021-02-08T18:52:56Z" | 1b2472825664763c0b88807b0d193e73553423ec | 2681633db8d340d2dc59cf801419874d572fc704 | markup/goldmark: Add attributes support for blocks (tables etc.). Fixes #7548 | ./hugolib/gitinfo.go | // Copyright 2019 The Hugo Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package hugolib
import (
"path/filepath"
"strings"
"github.com/bep/gitmap"
"github.com/gohugoio/hugo/config"
"github.com/gohugoio/hugo/resources/page"
)
type gitInfo struct {
contentDir string
repo *gitmap.GitRepo
}
func (g *gitInfo) forPage(p page.Page) *gitmap.GitInfo {
name := strings.TrimPrefix(filepath.ToSlash(p.File().Filename()), g.contentDir)
name = strings.TrimPrefix(name, "/")
return g.repo.Files[name]
}
func newGitInfo(cfg config.Provider) (*gitInfo, error) {
workingDir := cfg.GetString("workingDir")
gitRepo, err := gitmap.Map(workingDir, "")
if err != nil {
return nil, err
}
return &gitInfo{contentDir: gitRepo.TopLevelAbsPath, repo: gitRepo}, nil
}
| // Copyright 2019 The Hugo Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package hugolib
import (
"path/filepath"
"strings"
"github.com/bep/gitmap"
"github.com/gohugoio/hugo/config"
"github.com/gohugoio/hugo/resources/page"
)
type gitInfo struct {
contentDir string
repo *gitmap.GitRepo
}
func (g *gitInfo) forPage(p page.Page) *gitmap.GitInfo {
name := strings.TrimPrefix(filepath.ToSlash(p.File().Filename()), g.contentDir)
name = strings.TrimPrefix(name, "/")
return g.repo.Files[name]
}
func newGitInfo(cfg config.Provider) (*gitInfo, error) {
workingDir := cfg.GetString("workingDir")
gitRepo, err := gitmap.Map(workingDir, "")
if err != nil {
return nil, err
}
return &gitInfo{contentDir: gitRepo.TopLevelAbsPath, repo: gitRepo}, nil
}
| -1 |
gohugoio/hugo | 8,215 | markup/goldmark: Add attributes support for blocks (tables etc.) | Fixes #7548 | bep | "2021-02-08T09:42:41Z" | "2021-02-08T18:52:56Z" | 1b2472825664763c0b88807b0d193e73553423ec | 2681633db8d340d2dc59cf801419874d572fc704 | markup/goldmark: Add attributes support for blocks (tables etc.). Fixes #7548 | ./docs/content/en/news/0.58.0-relnotes/hugo58-featured.png | PNG
IHDR 2 t gAMA a sRGB PLTE'.8"-CEH28D#nV8V5#"XpL9?Ldkve
wxybjui-4Aiq}ZELXY`l8?L3:G;BNikmPWc7>IWZ]ęfks~&,8Ԥh&"[Y`j֕I:-2=r&L
K+*04:(/ /"111?)Z<'!.%)A;83235 J+/<#J*VE:Z.ӣh5!=$;"(23 *001]G:i%!eB6!*!>$I*%/9)& [@7*QD;Øf !-,,&-0)!hM:8$.4%'-6& # $ &
fF/1"e%!F(3Y<+%(/0(5'0-
%+?-(--Y/$ 5!bB6#G(3
-'
T9#(P5"
(
0;+ +($$
)$ ,+!*+)!%!
*- !]=)1$("6(h$2 &! CP[-(PS:91Ϲx|孯'
^Tx2M0#(~0&qX#`embpu}4'@%-@/2!NS](M2
s\_C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