#131 Ignore non-latest symlinks
Merged a year ago by lsedlar. Opened a year ago by lsedlar.
lsedlar/compose-utils ignore-non-latest-symlinks  into  master

file modified
+3 -2
@@ -108,9 +108,10 @@ 

  

      def ver_len(s):

          return s.count(".")

-     # Find all symlinks in the directory.

+     # Find all latest symlinks in the directory.

      all_symlinks = filter(

-         lambda x: os.path.islink(os.path.join(compose_path, x)), os.listdir(compose_path)

+         lambda x: os.path.islink(os.path.join(compose_path, x)),

+         (x for x in os.listdir(compose_path) if latest_symlink_re.match(x)),

      )

      # Filter the ones with most version components.

      links = sorted(all_symlinks, key=ver_len, reverse=True)

file modified
+8
@@ -175,3 +175,11 @@ 

          self.assert_symlink('latest-DP-1.1-B-2', 'latest-DP-1.1.0-B-2')

          self.assert_symlink('latest-DP-1.2-B-2', 'latest-DP-1.2.0-B-2')

          self.assert_symlink('latest-DP-1.3-B-2', 'latest-DP-1.3.0-B-2')

+ 

+     def test_ignore_non_latest_symlink(self):

+         self.create_full_symlink('latest-DP-1.0')

+         self.create_full_symlink('DP-1.0-20230510.0')

+ 

+         symlink.update_symlinks(self.compose_dir)

+ 

+         self.assert_symlink('latest-DP-1', 'latest-DP-1.0')

no initial comment

Pull-Request has been merged by lsedlar

a year ago