From 4b74c43a0b733670b6a50d86c935dd3fcdce6de4 Mon Sep 17 00:00:00 2001 From: Shelby Sturgis Date: Mon, 25 Jan 2016 10:41:49 -0800 Subject: [PATCH 01/14] removing split chart option for tile map visualization --- src/plugins/kbn_vislib_vis_types/public/tileMap.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/plugins/kbn_vislib_vis_types/public/tileMap.js b/src/plugins/kbn_vislib_vis_types/public/tileMap.js index 0b7860a5147c..c02d46e24808 100644 --- a/src/plugins/kbn_vislib_vis_types/public/tileMap.js +++ b/src/plugins/kbn_vislib_vis_types/public/tileMap.js @@ -111,13 +111,6 @@ define(function (require) { aggFilter: 'geohash_grid', min: 1, max: 1 - }, - { - group: 'buckets', - name: 'split', - title: 'Split Chart', - min: 0, - max: 1 } ]) }); From 0ee2bc7622d173a5241320efb7e4b6445efbfa16 Mon Sep 17 00:00:00 2001 From: Shelby Sturgis Date: Mon, 25 Jan 2016 10:41:49 -0800 Subject: [PATCH 02/14] Closes #5728. Removing split chart option for tile map visualization. --- src/plugins/kbn_vislib_vis_types/public/tileMap.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/plugins/kbn_vislib_vis_types/public/tileMap.js b/src/plugins/kbn_vislib_vis_types/public/tileMap.js index 0b7860a5147c..c02d46e24808 100644 --- a/src/plugins/kbn_vislib_vis_types/public/tileMap.js +++ b/src/plugins/kbn_vislib_vis_types/public/tileMap.js @@ -111,13 +111,6 @@ define(function (require) { aggFilter: 'geohash_grid', min: 1, max: 1 - }, - { - group: 'buckets', - name: 'split', - title: 'Split Chart', - min: 0, - max: 1 } ]) }); From 8e1bec8bd8d3048c17a2c8aaa522ffec261d8572 Mon Sep 17 00:00:00 2001 From: Shelby Sturgis Date: Fri, 29 Jan 2016 10:07:41 -0800 Subject: [PATCH 03/14] removing splits from geo_json converter in tests --- src/ui/public/agg_response/geo_json/__tests__/geo_json.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/ui/public/agg_response/geo_json/__tests__/geo_json.js b/src/ui/public/agg_response/geo_json/__tests__/geo_json.js index f4ad5d637e61..1dfe8917c461 100644 --- a/src/ui/public/agg_response/geo_json/__tests__/geo_json.js +++ b/src/ui/public/agg_response/geo_json/__tests__/geo_json.js @@ -23,7 +23,6 @@ describe('GeoJson Agg Response Converter', function () { type: 'tile_map', aggs: [ { schema: 'metric', type: 'avg', params: { field: 'bytes' } }, - { schema: 'split', type: 'terms', params: { field: '@tags' } }, { schema: 'segment', type: 'geohash_grid', params: { field: 'geo.coordinates', precision: 3 } } ], params: { @@ -34,7 +33,6 @@ describe('GeoJson Agg Response Converter', function () { aggs = { metric: vis.aggs[0], - split: vis.aggs[1], geo: vis.aggs[2] }; })); From 8072b043d7355c3d92760c57fe221461d73e6525 Mon Sep 17 00:00:00 2001 From: Shelby Sturgis Date: Wed, 2 Mar 2016 10:58:51 -0800 Subject: [PATCH 04/14] troubleshooting test failures --- src/fixtures/agg_resp/geohash_grid.js | 22 ++++++++++--------- .../geo_json/__tests__/geo_json.js | 2 +- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/fixtures/agg_resp/geohash_grid.js b/src/fixtures/agg_resp/geohash_grid.js index b62d56d21ae5..6f14f13921d7 100644 --- a/src/fixtures/agg_resp/geohash_grid.js +++ b/src/fixtures/agg_resp/geohash_grid.js @@ -47,16 +47,18 @@ export default function GeoHashGridAggResponseFixture() { }; }); - return { - key: 'tag ' + (i + 1), - doc_count: docCount, - 3: { - buckets: buckets - }, - 1: { - value: 1000 + i - } - }; + return tags; + + //return { + // key: 'tag ' + (i + 1), + //doc_count: docCount, + // 3: { + // buckets: buckets + // }, + // 1: { + // value: 1000 + i + // } + //}; }); return { diff --git a/src/ui/public/agg_response/geo_json/__tests__/geo_json.js b/src/ui/public/agg_response/geo_json/__tests__/geo_json.js index 0b2f794e72fa..c5f3beca2eda 100644 --- a/src/ui/public/agg_response/geo_json/__tests__/geo_json.js +++ b/src/ui/public/agg_response/geo_json/__tests__/geo_json.js @@ -38,7 +38,7 @@ describe('GeoJson Agg Response Converter', function () { aggs = { metric: vis.aggs[0], - geo: vis.aggs[2] + geo: vis.aggs[1] }; })); From 392063ca4c766c0ebc41fa4021e3873080ce7415 Mon Sep 17 00:00:00 2001 From: Shelby Sturgis Date: Wed, 2 Mar 2016 11:09:17 -0800 Subject: [PATCH 05/14] fixing minor bug --- src/fixtures/agg_resp/geohash_grid.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fixtures/agg_resp/geohash_grid.js b/src/fixtures/agg_resp/geohash_grid.js index 6f14f13921d7..f571c6007d73 100644 --- a/src/fixtures/agg_resp/geohash_grid.js +++ b/src/fixtures/agg_resp/geohash_grid.js @@ -47,7 +47,7 @@ export default function GeoHashGridAggResponseFixture() { }; }); - return tags; + return buckets; //return { // key: 'tag ' + (i + 1), From 4d167b4090d3c2e4444cdcc071874cb49199f411 Mon Sep 17 00:00:00 2001 From: Shelby Sturgis Date: Wed, 2 Mar 2016 12:47:08 -0800 Subject: [PATCH 06/14] fixing failing tests --- src/fixtures/agg_resp/geohash_grid.js | 49 ++++++------------- .../geo_json/__tests__/geo_json.js | 2 +- 2 files changed, 16 insertions(+), 35 deletions(-) diff --git a/src/fixtures/agg_resp/geohash_grid.js b/src/fixtures/agg_resp/geohash_grid.js index f571c6007d73..641e87e6bc09 100644 --- a/src/fixtures/agg_resp/geohash_grid.js +++ b/src/fixtures/agg_resp/geohash_grid.js @@ -8,7 +8,6 @@ export default function GeoHashGridAggResponseFixture() { // type: 'tile_map', // aggs:[ // { schema: 'metric', type: 'avg', params: { field: 'bytes' } }, - // { schema: 'split', type: 'terms', params: { field: '@tags', size: 10 } }, // { schema: 'segment', type: 'geohash_grid', params: { field: 'geo.coordinates', precision: 3 } } // ], // params: { @@ -25,40 +24,22 @@ export default function GeoHashGridAggResponseFixture() { var totalDocCount = 0; - var tags = _.times(_.random(4, 20), function (i) { - // random number of tags - var docCount = 0; - var buckets = _.times(_.random(40, 200), function () { - return _.sample(geoHashCharts, 3).join(''); - }) - .sort() - .map(function (geoHash) { - var count = _.random(1, 5000); + var buckets = _.times(_.random(40, 200), function () { + return _.sample(geoHashCharts, 3).join(''); + }) + .sort() + .map(function (geoHash, i) { + var count = _.random(1, 5000); - totalDocCount += count; - docCount += count; + totalDocCount += count; - return { - key: geoHash, - doc_count: count, - 1: { - value: 2048 + i - } - }; - }); - - return buckets; - - //return { - // key: 'tag ' + (i + 1), - //doc_count: docCount, - // 3: { - // buckets: buckets - // }, - // 1: { - // value: 1000 + i - // } - //}; + return { + key: geoHash, + doc_count: count, + 1: { + value: 2048 + i + } + }; }); return { @@ -76,7 +57,7 @@ export default function GeoHashGridAggResponseFixture() { }, aggregations: { 2: { - buckets: tags + buckets: buckets } } }; diff --git a/src/ui/public/agg_response/geo_json/__tests__/geo_json.js b/src/ui/public/agg_response/geo_json/__tests__/geo_json.js index c5f3beca2eda..9dc870a397dd 100644 --- a/src/ui/public/agg_response/geo_json/__tests__/geo_json.js +++ b/src/ui/public/agg_response/geo_json/__tests__/geo_json.js @@ -45,7 +45,7 @@ describe('GeoJson Agg Response Converter', function () { [ { asAggConfigResults: true }, { asAggConfigResults: false } ].forEach(function (tableOpts) { function makeTable() { - return _.sample(_.sample(tabify(vis, esResponse, tableOpts).tables).tables); + return _.sample(tabify(vis, esResponse, tableOpts).tables); } function makeSingleChart(table) { From 3ea364ff05ed4216aab70ef7115baf355fe6fe86 Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Thu, 17 Mar 2016 17:47:52 -0700 Subject: [PATCH 07/14] change main navbar back, drop the -options --- src/plugins/kibana/public/dashboard/index.html | 2 +- src/plugins/kibana/public/discover/index.html | 2 +- src/plugins/kibana/public/visualize/editor/editor.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/kibana/public/dashboard/index.html b/src/plugins/kibana/public/dashboard/index.html index 042f90b7aba6..e4d8c5523e37 100644 --- a/src/plugins/kibana/public/dashboard/index.html +++ b/src/plugins/kibana/public/dashboard/index.html @@ -1,5 +1,5 @@
- +
diff --git a/src/plugins/kibana/public/discover/index.html b/src/plugins/kibana/public/discover/index.html index bf39d0e25d9d..19fd39794417 100644 --- a/src/plugins/kibana/public/discover/index.html +++ b/src/plugins/kibana/public/discover/index.html @@ -1,5 +1,5 @@
- +
diff --git a/src/plugins/kibana/public/visualize/editor/editor.html b/src/plugins/kibana/public/visualize/editor/editor.html index 141d7c06d66c..154102f7495a 100644 --- a/src/plugins/kibana/public/visualize/editor/editor.html +++ b/src/plugins/kibana/public/visualize/editor/editor.html @@ -1,5 +1,5 @@
- +
From 84065742fbece3873a1c576d5bd8f895ae284308 Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Thu, 17 Mar 2016 18:00:47 -0700 Subject: [PATCH 08/14] move the chrom nav controls out of the main button group it was messing up button injection, and looks like it didn't need to be there anyway --- src/plugins/kibana/public/dashboard/index.html | 2 +- src/plugins/kibana/public/discover/index.html | 2 +- src/plugins/kibana/public/visualize/editor/editor.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/kibana/public/dashboard/index.html b/src/plugins/kibana/public/dashboard/index.html index e4d8c5523e37..7c52c846db10 100644 --- a/src/plugins/kibana/public/dashboard/index.html +++ b/src/plugins/kibana/public/dashboard/index.html @@ -51,8 +51,8 @@ ng-click="configTemplate.toggle('options');"> Options -
+
diff --git a/src/plugins/kibana/public/discover/index.html b/src/plugins/kibana/public/discover/index.html index 19fd39794417..3032ab00f370 100644 --- a/src/plugins/kibana/public/discover/index.html +++ b/src/plugins/kibana/public/discover/index.html @@ -39,8 +39,8 @@ ng-click="configTemplate.toggle('share');"> Share -
+
Refresh -
+
Date: Mon, 21 Mar 2016 13:36:00 -0700 Subject: [PATCH 09/14] change timepicker selector --- test/support/pages/discover_page.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/support/pages/discover_page.js b/test/support/pages/discover_page.js index b5638a18882b..62604fe27178 100644 --- a/test/support/pages/discover_page.js +++ b/test/support/pages/discover_page.js @@ -28,7 +28,7 @@ define(function (require) { getTimespanText: function getTimespanText() { return thisTime - .findByCssSelector('.kibana-nav-actions .navbar-timepicker-time-desc pretty-duration') + .findByCssSelector('.kibana-nav-options .navbar-timepicker-time-desc pretty-duration') .getVisibleText(); }, From 7314ef6c6045bed7f7449b8abfea1d51cb73b423 Mon Sep 17 00:00:00 2001 From: Shelby Sturgis Date: Fri, 25 Mar 2016 15:48:14 -0700 Subject: [PATCH 10/14] replacing split chart ability --- src/fixtures/agg_resp/geohash_grid.js | 39 +++++++++++++------ .../kbn_vislib_vis_types/public/tile_map.js | 8 ++++ .../geo_json/__tests__/geo_json.js | 6 ++- 3 files changed, 40 insertions(+), 13 deletions(-) diff --git a/src/fixtures/agg_resp/geohash_grid.js b/src/fixtures/agg_resp/geohash_grid.js index 641e87e6bc09..b62d56d21ae5 100644 --- a/src/fixtures/agg_resp/geohash_grid.js +++ b/src/fixtures/agg_resp/geohash_grid.js @@ -8,6 +8,7 @@ export default function GeoHashGridAggResponseFixture() { // type: 'tile_map', // aggs:[ // { schema: 'metric', type: 'avg', params: { field: 'bytes' } }, + // { schema: 'split', type: 'terms', params: { field: '@tags', size: 10 } }, // { schema: 'segment', type: 'geohash_grid', params: { field: 'geo.coordinates', precision: 3 } } // ], // params: { @@ -24,20 +25,36 @@ export default function GeoHashGridAggResponseFixture() { var totalDocCount = 0; - var buckets = _.times(_.random(40, 200), function () { - return _.sample(geoHashCharts, 3).join(''); - }) - .sort() - .map(function (geoHash, i) { - var count = _.random(1, 5000); + var tags = _.times(_.random(4, 20), function (i) { + // random number of tags + var docCount = 0; + var buckets = _.times(_.random(40, 200), function () { + return _.sample(geoHashCharts, 3).join(''); + }) + .sort() + .map(function (geoHash) { + var count = _.random(1, 5000); - totalDocCount += count; + totalDocCount += count; + docCount += count; + + return { + key: geoHash, + doc_count: count, + 1: { + value: 2048 + i + } + }; + }); return { - key: geoHash, - doc_count: count, + key: 'tag ' + (i + 1), + doc_count: docCount, + 3: { + buckets: buckets + }, 1: { - value: 2048 + i + value: 1000 + i } }; }); @@ -57,7 +74,7 @@ export default function GeoHashGridAggResponseFixture() { }, aggregations: { 2: { - buckets: buckets + buckets: tags } } }; diff --git a/src/plugins/kbn_vislib_vis_types/public/tile_map.js b/src/plugins/kbn_vislib_vis_types/public/tile_map.js index 7b673a52a3ea..824177545ff7 100644 --- a/src/plugins/kbn_vislib_vis_types/public/tile_map.js +++ b/src/plugins/kbn_vislib_vis_types/public/tile_map.js @@ -116,6 +116,14 @@ export default function TileMapVisType(Private, getAppState, courier, config) { aggFilter: 'geohash_grid', min: 1, max: 1 + }, + { + group: 'buckets', + name: 'split', + title: 'Split Chart', + deprecate: true, + min: 0, + max: 1 } ]) }); diff --git a/src/ui/public/agg_response/geo_json/__tests__/geo_json.js b/src/ui/public/agg_response/geo_json/__tests__/geo_json.js index 64d8ffa55d48..78fc73fdd6c2 100644 --- a/src/ui/public/agg_response/geo_json/__tests__/geo_json.js +++ b/src/ui/public/agg_response/geo_json/__tests__/geo_json.js @@ -28,6 +28,7 @@ describe('GeoJson Agg Response Converter', function () { type: 'tile_map', aggs: [ { schema: 'metric', type: 'avg', params: { field: 'bytes' } }, + { schema: 'split', type: 'terms', params: { field: '@tags' } }, { schema: 'segment', type: 'geohash_grid', params: { field: 'geo.coordinates', precision: 3 } } ], params: { @@ -38,14 +39,15 @@ describe('GeoJson Agg Response Converter', function () { aggs = { metric: vis.aggs[0], - geo: vis.aggs[1] + split: vis.aggs[1], + geo: vis.aggs[2] }; })); [ { asAggConfigResults: true }, { asAggConfigResults: false } ].forEach(function (tableOpts) { function makeTable() { - return _.sample(tabify(vis, esResponse, tableOpts).tables); + return _.sample(_.sample(tabify(vis, esResponse, tableOpts).tables).tables); } function makeSingleChart(table) { From 07817ba71ec75fe3510f364398388f3c2a77f1ad Mon Sep 17 00:00:00 2001 From: Shelby Sturgis Date: Fri, 25 Mar 2016 17:52:45 -0700 Subject: [PATCH 11/14] adding ability to hide agg schema when deprecated --- src/plugins/kibana/public/visualize/editor/agg_add.html | 3 ++- src/plugins/kibana/public/visualize/editor/agg_group.js | 5 ++++- src/ui/public/vis/schemas.js | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/plugins/kibana/public/visualize/editor/agg_add.html b/src/plugins/kibana/public/visualize/editor/agg_add.html index d1de5c7f1ee7..ba7135f6daa8 100644 --- a/src/plugins/kibana/public/visualize/editor/agg_add.html +++ b/src/plugins/kibana/public/visualize/editor/agg_add.html @@ -2,6 +2,7 @@
  • @@ -21,7 +22,7 @@
    Add {{ groupName }}
    -
    +
    Add sub-{{ groupName }}
    diff --git a/src/plugins/kibana/public/visualize/editor/agg_group.js b/src/plugins/kibana/public/visualize/editor/agg_group.js index 52efea728f25..d0223fa90ef0 100644 --- a/src/plugins/kibana/public/visualize/editor/agg_group.js +++ b/src/plugins/kibana/public/visualize/editor/agg_group.js @@ -25,7 +25,10 @@ uiModules const stats = $scope.stats = { min: 0, max: 0, - count: $scope.group ? $scope.group.length : 0 + count: $scope.group ? $scope.group.length : 0, + numDeprecated: $scope.schemas.raw.filter(function (o) { + return o.deprecate; + }).length }; if (!$scope.schemas) return; diff --git a/src/ui/public/vis/schemas.js b/src/ui/public/vis/schemas.js index 37fed2929194..3eeea29d6be7 100644 --- a/src/ui/public/vis/schemas.js +++ b/src/ui/public/vis/schemas.js @@ -30,7 +30,8 @@ export default function VisTypeSchemasFactory(Private) { title: schema.name, aggFilter: '*', editor: false, - params: [] + params: [], + deprecate: false }); // convert the params into a params registry From 02bef3078363375e256682557be5e105bdca3e0a Mon Sep 17 00:00:00 2001 From: Shelby Sturgis Date: Mon, 28 Mar 2016 14:46:09 -0700 Subject: [PATCH 12/14] reworking the pr based on new design spec. see pr comments --- src/plugins/kibana/public/visualize/editor/agg_add.html | 4 ++-- src/plugins/kibana/public/visualize/editor/agg_group.js | 6 ++---- .../kibana/public/visualize/editor/agg_params.html | 8 +++++++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/plugins/kibana/public/visualize/editor/agg_add.html b/src/plugins/kibana/public/visualize/editor/agg_add.html index ba7135f6daa8..0ce5acbfb9fa 100644 --- a/src/plugins/kibana/public/visualize/editor/agg_add.html +++ b/src/plugins/kibana/public/visualize/editor/agg_add.html @@ -19,10 +19,10 @@ class="vis-editor-agg-wide-btn">
    -
    +
    Add {{ groupName }}
    -
    +
    Add sub-{{ groupName }}
    diff --git a/src/plugins/kibana/public/visualize/editor/agg_group.js b/src/plugins/kibana/public/visualize/editor/agg_group.js index d0223fa90ef0..1718d80c1b58 100644 --- a/src/plugins/kibana/public/visualize/editor/agg_group.js +++ b/src/plugins/kibana/public/visualize/editor/agg_group.js @@ -25,10 +25,7 @@ uiModules const stats = $scope.stats = { min: 0, max: 0, - count: $scope.group ? $scope.group.length : 0, - numDeprecated: $scope.schemas.raw.filter(function (o) { - return o.deprecate; - }).length + count: $scope.group ? $scope.group.length : 0 }; if (!$scope.schemas) return; @@ -36,6 +33,7 @@ uiModules $scope.schemas.forEach(function (schema) { stats.min += schema.min; stats.max += schema.max; + stats.deprecate = schema.deprecate; }); $scope.availableSchema = $scope.schemas.filter(function (schema) { diff --git a/src/plugins/kibana/public/visualize/editor/agg_params.html b/src/plugins/kibana/public/visualize/editor/agg_params.html index e4473e73a8b2..6a3c8c7cf387 100644 --- a/src/plugins/kibana/public/visualize/editor/agg_params.html +++ b/src/plugins/kibana/public/visualize/editor/agg_params.html @@ -10,4 +10,10 @@ style="display: none;">
    - \ No newline at end of file +
    +

    + "{{ agg.schema.title }}" has been deprecated. +

    +
    + + From b9e685f398a458dc0c2e9d6db7b560123add99a8 Mon Sep 17 00:00:00 2001 From: Shelby Sturgis Date: Mon, 28 Mar 2016 17:00:30 -0700 Subject: [PATCH 13/14] adding option to specify custome deprecate message --- src/plugins/kbn_vislib_vis_types/public/tile_map.js | 1 + src/plugins/kibana/public/visualize/editor/agg_params.html | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/plugins/kbn_vislib_vis_types/public/tile_map.js b/src/plugins/kbn_vislib_vis_types/public/tile_map.js index 824177545ff7..acc7e4591848 100644 --- a/src/plugins/kbn_vislib_vis_types/public/tile_map.js +++ b/src/plugins/kbn_vislib_vis_types/public/tile_map.js @@ -122,6 +122,7 @@ export default function TileMapVisType(Private, getAppState, courier, config) { name: 'split', title: 'Split Chart', deprecate: true, + deprecateMessage: 'The Split Chart feature for Tile Maps has been deprecated.', min: 0, max: 1 } diff --git a/src/plugins/kibana/public/visualize/editor/agg_params.html b/src/plugins/kibana/public/visualize/editor/agg_params.html index 6a3c8c7cf387..5f822ada4f0e 100644 --- a/src/plugins/kibana/public/visualize/editor/agg_params.html +++ b/src/plugins/kibana/public/visualize/editor/agg_params.html @@ -11,7 +11,10 @@
    -

    +

    + {{ agg.schema.deprecateMessage }} +

    +

    "{{ agg.schema.title }}" has been deprecated.

    From 55e429cc4ff4fd3e3c711e9962e68ac92d965f23 Mon Sep 17 00:00:00 2001 From: Court Ewing Date: Tue, 29 Mar 2016 13:24:24 -0400 Subject: [PATCH 14/14] [internal] Reject CI builds if any .rej files exist .rej are the byproduct of failed patches via git-apply or artifacts of the backporting process through jasper. Any build that has them should be rejected early. --- tasks/jenkins.js | 1 + tasks/reject_rej_files.js | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 tasks/reject_rej_files.js diff --git a/tasks/jenkins.js b/tasks/jenkins.js index 77a2673cffb7..141f8084a9ec 100644 --- a/tasks/jenkins.js +++ b/tasks/jenkins.js @@ -16,6 +16,7 @@ module.exports = function (grunt) { grunt.option('os-packages', true); grunt.task.run(compact([ + 'rejectRejFiles', 'test', process.env.JOB_NAME === 'kibana_core' ? 'build' : null ])); diff --git a/tasks/reject_rej_files.js b/tasks/reject_rej_files.js new file mode 100644 index 000000000000..33c8c3273fa5 --- /dev/null +++ b/tasks/reject_rej_files.js @@ -0,0 +1,30 @@ +import { startsWith } from 'lodash'; + +// Fails if any .rej files are found +// .rej files are an artifact from a failed git-apply or a jasper backport + +// This check is intentionally performed on the files in the repo rather than +// on the files that are to be committed. + +export default grunt => { + grunt.registerTask('rejectRejFiles', 'Reject any git-apply .rej files', () => { + const ignoredTopLevelDirs = [ + 'esvm', + 'installedPlugins', + 'node_modules', + 'optimize' + ]; + + const matchBase = true; + const filter = file => ( + ignoredTopLevelDirs.every(dir => !startsWith(file, dir)) + ); + + const files = grunt.file.expand({ filter, matchBase }, '*.rej'); + if (files.length > 0) { + const err = `.rej files are not allowed:\n${files.join('\n')}`; + grunt.log.error(err); + return false; + } + }); +};