You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2023/04/04 21:04:06 UTC
[sling-aggregator] branch master updated: SLING-11709 - Set up Jira autolinks to all Sling Github projects (#8)
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-aggregator.git
The following commit(s) were added to refs/heads/master by this push:
new dd39111 SLING-11709 - Set up Jira autolinks to all Sling Github projects (#8)
dd39111 is described below
commit dd39111f2f59a029e5cce94442205de79e2a2ea3
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Tue Apr 4 23:04:02 2023 +0200
SLING-11709 - Set up Jira autolinks to all Sling Github projects (#8)
Create a script to automate .asf.yaml maintenance
---
README.md | 17 +++++++++
scripts/update-asf-yaml.groovy | 78 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 95 insertions(+)
diff --git a/README.md b/README.md
index ff1a93c..194f4b4 100644
--- a/README.md
+++ b/README.md
@@ -35,6 +35,23 @@ To update all repositories:
repo forall -c '[SLING_DIR]/aggregator/generate-project-badges.groovy .'
+### Updating the .asf.yaml files
+
+We maintain a set of [.asf.yaml](https://cwiki.apache.org/confluence/display/INFRA/Git+-+.asf.yaml+features) files, to set reasonable defaults for all Sling GitHub repositories. To make maintenance simple, we use the [scripts/update-asf-yaml.groovy](scripts/update-asf-yaml.groovy).
+
+The script accepts a list of directories to generate or update the listing file for.
+
+```bash
+$ repo list --path-only | xargs groovy aggregator/scripts/update-asf-yaml.groovy
+$ repo forall -c 'git add .asf.yaml'
+$ repo forall -c 'git commit -m "SLING-12345 Updating .asf.yaml" -m "Detailed description"'
+```
+
+Once you are happy with what the commits look like you can push the changes, with a delay, using
+
+```bash
+$ repo for all -c 'sleep 3; git push'
+```
### Updating the Aggregator List
diff --git a/scripts/update-asf-yaml.groovy b/scripts/update-asf-yaml.groovy
new file mode 100644
index 0000000..6ccfc83
--- /dev/null
+++ b/scripts/update-asf-yaml.groovy
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+import groovy.cli.commons.CliBuilder
+import groovy.yaml.YamlBuilder
+import groovy.yaml.YamlSlurper
+
+def documentSeparator = "---\n"
+def cli = new CliBuilder(usage: 'update-asf-yaml.groovy <directories...>')
+
+def options = cli.parse(args)
+if ( !options || !options.arguments() || !options.arguments().size() == 0 ) {
+ cli.usage()
+ System.exit 1
+}
+
+options.arguments().forEach { arg ->
+
+ def targetDir = new File(arg)
+ if ( !targetDir.isDirectory() ) {
+ println "Target directory ${targetDir} does not exist or is not a directory, aborting"
+ System.exit 1
+ }
+ def targetFile = new File(targetDir, '.asf.yaml')
+ def asfYaml = [:]
+ if ( !targetFile.exists() ) {
+ println "Target file ${targetFile} does not exist, creating with defaults"
+ } else {
+ println "Target file ${targetFile} exists, merging with defaults"
+ def parser = new YamlSlurper()
+ asfYaml = parser.parse(targetFile)
+ }
+
+ if ( ! asfYaml['github'] ) {
+ asfYaml['github'] = [:]
+ }
+
+ // set up autolinks ; note: missing merge
+ // https://cwiki.apache.org/confluence/display/INFRA/Git+-+.asf.yaml+features#Git.asf.yamlfeatures-AutolinksforJira
+ def autolinks = asfYaml['github']['autolinks']
+ if ( ! autolinks ) {
+ asfYaml['github']['autolink_jira'] = ['SLING', 'OAK', 'JCR', 'JCRVLT', 'INFRA','FELIX', 'MNG']
+ }
+
+ if ( !asfYaml['notifications'] ) {
+ asfYaml['notifications'] = [:]
+ }
+ // set up jira integration
+ // https://cwiki.apache.org/confluence/display/INFRA/Git+-+.asf.yaml+features#Git.asf.yamlfeatures-Jiranotificationoptions
+ def jiraOptions = asfYaml['notifications']['jira_options']
+ if ( !jiraOptions ) {
+ asfYaml['notifications']['jira_options'] = 'link'
+ }
+ def builder = new YamlBuilder()
+ builder(asfYaml)
+
+ targetFile.text = ''
+ def rawYaml = builder.toString()
+ if ( rawYaml.startsWith(documentSeparator) ) {
+ rawYaml = rawYaml - documentSeparator
+ }
+ targetFile << rawYaml
+}