Skip to content

Rewrite package-submodule-blacklist to python, make it work on both client and server#7

Open
dmach wants to merge 1 commit into
mainfrom
package-submodule-blacklist-python
Open

Rewrite package-submodule-blacklist to python, make it work on both client and server#7
dmach wants to merge 1 commit into
mainfrom
package-submodule-blacklist-python

Conversation

@dmach

@dmach dmach commented May 27, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@dmach dmach requested a review from eliroca May 27, 2026 09:13

@eliroca eliroca left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In my testing we're missing the case when there is no _manifest file.

diff --git a/src/all-hooks/package-submodule-blacklist b/src/all-hooks/package-submodule-blacklist
index f153b74..a548809 100755
--- a/src/all-hooks/package-submodule-blacklist
+++ b/src/all-hooks/package-submodule-blacklist
@@ -7,8 +7,8 @@ import sys
 if os.environ.get("PACKAGE_SUBMODULE_BLACKLIST_SKIP", None):
     sys.exit(0)
 
-from osc.git_scm import GitStore
-from osc.gitea_api import Git
+from osc.git_scm.store import GitStore
+from osc.gitea_api.git import Git
 
 
 BLACKLIST_FILE = ".git-workflow/hooks/package-submodule-blacklist.txt"
@@ -25,7 +25,10 @@ def check_revision(rev: str) -> bool:
     store = GitStore(".", ref=rev, check=False)
     git = store._git
 
-    if git.is_bare:
+    if store.manifest is None:
+        directories = git.ls_tree(rev)
+        package_paths = [i["path"] for i in directories if i["file_type"] in ("directory", "submodule")]
+    elif git.is_bare:
         directories = git.ls_tree(rev)
         directories = [i["path"] for i in directories if i["file_type"] in ("directory", "submodule")]
         package_paths = store.manifest.get_package_paths_bare_git(store.topdir, directories=directories)
@@ -99,7 +102,7 @@ def main():
 
     for old_rev, new_rev in rev_list:
         # we want to enable 'not_all' only in the pre-receive hook
-        commits = git.get_commit_range(old_rev, new_rev, not_all=is_pre_receive)
+        commits = git.get_commit_range(old_rev, new_rev, not_all=bool(is_pre_receive))
         for sha in commits:
             if sha in seen:
                 continue

@dmach dmach force-pushed the package-submodule-blacklist-python branch from 3bc9846 to d931005 Compare June 18, 2026 18:19
@dmach

dmach commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator Author

Could you give it another try?
It seems it's caused by bug I've fixed in openSUSE/osc#2169.
Normally, if there's no _manifest, osc sets store.manifest = Manifest({}) and that considers all top-level directories packages.
I've added a unit test for this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants