You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by "janhoy (via GitHub)" <gi...@apache.org> on 2023/03/23 00:43:16 UTC

[GitHub] [solr] janhoy opened a new pull request, #1483: SOLR-16714 Add dependency upgrades to CHANGES

janhoy opened a new pull request, #1483:
URL: https://github.com/apache/solr/pull/1483

   https://issues.apache.org/jira/browse/SOLR-16714
   
   Here is a python script that runs `git log` to find all `solrbot` commits since last release.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] janhoy commented on a diff in pull request #1483: SOLR-16714 Add dependency upgrades to CHANGES

Posted by "janhoy (via GitHub)" <gi...@apache.org>.
janhoy commented on code in PR #1483:
URL: https://github.com/apache/solr/pull/1483#discussion_r1145557521


##########
dev-tools/scripts/addDepsToChanges.py:
##########
@@ -0,0 +1,139 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# 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.
+
+"""
+Script to add solrbot changes lines to CHANGES.txt
+"""
+import os
+import sys
+
+sys.path.append(os.path.dirname(__file__))
+from scriptutil import *
+
+import argparse
+import re
+
+line_re = re.compile(r"(.*?) \(#(\d+)\)$")
+
+
+def get_prev_release_tag(ver):
+    """
+    Based on a given version, compute the git tag for the "previous" version to calculate changes since.
+    For a major version, we want all solrbot commits since last release, i.e. X-1.Y.Z
+    For a minor version, we want all solrbot commits since X.Y-1.0
+    For a patch version, we want all solrbot commits since X.Y.Z-1
+    """
+    releases_arr = run('git tag |grep "releases/solr" | cut -c 15-').strip().split("\n")
+    releases = list(map(lambda x: Version.parse(x), releases_arr))
+    if ver.is_major_release():
+        last = releases.pop()
+        return "releases/solr/%s" % last.dot
+    if ver.is_minor_release():
+        return "releases/solr/%s.%s.0" % (ver.major, ver.minor - 1)
+    if ver.is_bugfix_release():
+        return "releases/solr/%s.%s.%s" % (ver.major, ver.minor, ver.bugfix - 1)
+    return None
+
+
+def read_config():
+    parser = argparse.ArgumentParser(description='Adds dependency changes section to CHANGES.txt.')
+    parser.add_argument('--version', type=Version.parse, help='Solr version to add changes to', required=True)
+    parser.add_argument('--user', default='solrbot', help='Git user to get changes for. Defaults to solrbot')
+    newconf = parser.parse_args()
+    return newconf
+
+
+def gitlog_to_changes(line, user="solrbot"):
+    """
+    Converts a git log formatted line ending in (#<pr-num) into a CHANGES style line
+    """
+    match = line_re.search(line)
+
+    if match:
+        text = match.group(1)
+        pr_num = match.group(2)
+        return "* PR#%s: %s (%s)\n" % (pr_num, text, user)
+    else:
+        return None
+
+
+def update_changes(filename, version, changes_lines):
+    """
+    Edits CHANGES.txt in-place
+    """
+    buffer = []
+    found_ver = False
+    found_header = False
+    appended = False
+    with open(filename) as f:
+        version_re = re.compile(r' %s ===' % (version))
+        header_re = re.compile(r'^Dependency Upgrades')
+        header_line_re = re.compile(r'^----')
+        for line in f:
+            if not found_ver:
+                buffer.append(line)
+                if version_re.search(line):
+                    found_ver = True
+                continue
+            if not found_header:
+                buffer.append(line)
+                if header_re.search(line):
+                    found_header = True
+                continue
+            if not appended:
+                if header_line_re.search(line):
+                    buffer.append(line)
+                    appended = True
+                    for change_line in changes_lines:
+                        buffer.append(change_line)
+                        buffer.append("\n")
+                    continue
+            buffer.append(line)

Review Comment:
   This logic fins a `Dependency Upgrades` heading in the correct version section of CHANGES, and adds all entries directly below that heading. 
   
   TODO:
   * It won't delete the `(No changes)` line that would be there by default
   * If the release version does not contain a `Dependency Upgrades` heading, the script fails. This is not likely to happen, as the `addVersion.py` script now adds this header by default.
   * If a version does not contain the heading, but a version further down the file containst the heading, the script will add the entries to the wrong version, but this is also not very likely



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] janhoy merged pull request #1483: SOLR-16714 ReleaseWizard to add solrbot dependency upgrades to CHANGES

Posted by "janhoy (via GitHub)" <gi...@apache.org>.
janhoy merged PR #1483:
URL: https://github.com/apache/solr/pull/1483


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] janhoy commented on a diff in pull request #1483: SOLR-16714 Add dependency upgrades to CHANGES

Posted by "janhoy (via GitHub)" <gi...@apache.org>.
janhoy commented on code in PR #1483:
URL: https://github.com/apache/solr/pull/1483#discussion_r1145555914


##########
dev-tools/scripts/addDepsToChanges.py:
##########
@@ -0,0 +1,139 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# 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.
+
+"""
+Script to add solrbot changes lines to CHANGES.txt
+"""
+import os
+import sys
+
+sys.path.append(os.path.dirname(__file__))
+from scriptutil import *
+
+import argparse
+import re
+
+line_re = re.compile(r"(.*?) \(#(\d+)\)$")
+
+
+def get_prev_release_tag(ver):
+    """
+    Based on a given version, compute the git tag for the "previous" version to calculate changes since.
+    For a major version, we want all solrbot commits since last release, i.e. X-1.Y.Z
+    For a minor version, we want all solrbot commits since X.Y-1.0
+    For a patch version, we want all solrbot commits since X.Y.Z-1

Review Comment:
   Alternatively, for a major release, we could add all commits since `X-1.Y.0`, even if that would repeat some of the upgrades made in patch releases?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] janhoy commented on a diff in pull request #1483: SOLR-16714 Add dependency upgrades to CHANGES

Posted by "janhoy (via GitHub)" <gi...@apache.org>.
janhoy commented on code in PR #1483:
URL: https://github.com/apache/solr/pull/1483#discussion_r1145557521


##########
dev-tools/scripts/addDepsToChanges.py:
##########
@@ -0,0 +1,139 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# 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.
+
+"""
+Script to add solrbot changes lines to CHANGES.txt
+"""
+import os
+import sys
+
+sys.path.append(os.path.dirname(__file__))
+from scriptutil import *
+
+import argparse
+import re
+
+line_re = re.compile(r"(.*?) \(#(\d+)\)$")
+
+
+def get_prev_release_tag(ver):
+    """
+    Based on a given version, compute the git tag for the "previous" version to calculate changes since.
+    For a major version, we want all solrbot commits since last release, i.e. X-1.Y.Z
+    For a minor version, we want all solrbot commits since X.Y-1.0
+    For a patch version, we want all solrbot commits since X.Y.Z-1
+    """
+    releases_arr = run('git tag |grep "releases/solr" | cut -c 15-').strip().split("\n")
+    releases = list(map(lambda x: Version.parse(x), releases_arr))
+    if ver.is_major_release():
+        last = releases.pop()
+        return "releases/solr/%s" % last.dot
+    if ver.is_minor_release():
+        return "releases/solr/%s.%s.0" % (ver.major, ver.minor - 1)
+    if ver.is_bugfix_release():
+        return "releases/solr/%s.%s.%s" % (ver.major, ver.minor, ver.bugfix - 1)
+    return None
+
+
+def read_config():
+    parser = argparse.ArgumentParser(description='Adds dependency changes section to CHANGES.txt.')
+    parser.add_argument('--version', type=Version.parse, help='Solr version to add changes to', required=True)
+    parser.add_argument('--user', default='solrbot', help='Git user to get changes for. Defaults to solrbot')
+    newconf = parser.parse_args()
+    return newconf
+
+
+def gitlog_to_changes(line, user="solrbot"):
+    """
+    Converts a git log formatted line ending in (#<pr-num) into a CHANGES style line
+    """
+    match = line_re.search(line)
+
+    if match:
+        text = match.group(1)
+        pr_num = match.group(2)
+        return "* PR#%s: %s (%s)\n" % (pr_num, text, user)
+    else:
+        return None
+
+
+def update_changes(filename, version, changes_lines):
+    """
+    Edits CHANGES.txt in-place
+    """
+    buffer = []
+    found_ver = False
+    found_header = False
+    appended = False
+    with open(filename) as f:
+        version_re = re.compile(r' %s ===' % (version))
+        header_re = re.compile(r'^Dependency Upgrades')
+        header_line_re = re.compile(r'^----')
+        for line in f:
+            if not found_ver:
+                buffer.append(line)
+                if version_re.search(line):
+                    found_ver = True
+                continue
+            if not found_header:
+                buffer.append(line)
+                if header_re.search(line):
+                    found_header = True
+                continue
+            if not appended:
+                if header_line_re.search(line):
+                    buffer.append(line)
+                    appended = True
+                    for change_line in changes_lines:
+                        buffer.append(change_line)
+                        buffer.append("\n")
+                    continue
+            buffer.append(line)

Review Comment:
   This logic fins a `Dependency Upgrades` heading in the correct version section of CHANGES, and adds all entries directly below that heading. 
   
   TODO:
   * It won't delete the `(No changes)` line that would be there by default
   * If the release version does not contain a `Dependency Upgrades` heading, the script fails. This is not likely to happen, as the `addVersion.py` script now adds this header by default.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org