- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 6.2k
 
Fix submodule parsing #32571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
    
  
     Merged
                    Fix submodule parsing #32571
Changes from 6 commits
      Commits
    
    
            Show all changes
          
          
            7 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      342dffe
              
                Fix submodule parsing
              
              
                lunny f96ddce
              
                Recovery unnecessary changes
              
              
                lunny 2932f07
              
                rewrite parse submodule
              
              
                lunny 57bc3eb
              
                Fix bug
              
              
                lunny dc7ff6c
              
                Merge branch 'main' into lunny/fix_submodule_parse
              
              
                wxiaoguang 408bc11
              
                fix
              
              
                wxiaoguang 5f37364
              
                Merge branch 'main' into lunny/fix_submodule_parse
              
              
                GiteaBot File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| // Copyright 2024 The Gitea Authors. All rights reserved. | ||
| // SPDX-License-Identifier: MIT | ||
| 
     | 
||
| package git | ||
| 
     | 
||
| // GetSubModules get all the submodules of current revision git tree | ||
| func (c *Commit) GetSubModules() (*ObjectCache[*SubModule], error) { | ||
| if c.submoduleCache != nil { | ||
| return c.submoduleCache, nil | ||
| } | ||
| 
     | 
||
| entry, err := c.GetTreeEntryByPath(".gitmodules") | ||
| if err != nil { | ||
| if _, ok := err.(ErrNotExist); ok { | ||
| return nil, nil | ||
| } | ||
| return nil, err | ||
| } | ||
| 
     | 
||
| rd, err := entry.Blob().DataAsync() | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| defer rd.Close() | ||
| 
     | 
||
| // at the moment we do not strictly limit the size of the .gitmodules file because some users would have huge .gitmodules files (>1MB) | ||
| c.submoduleCache, err = configParseSubModules(rd) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| return c.submoduleCache, nil | ||
| } | ||
| 
     | 
||
| // GetSubModule get the submodule according entry name | ||
| func (c *Commit) GetSubModule(entryName string) (*SubModule, error) { | ||
| modules, err := c.GetSubModules() | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| 
     | 
||
| if modules != nil { | ||
| if module, has := modules.Get(entryName); has { | ||
| return module, nil | ||
| } | ||
| } | ||
| return nil, nil | ||
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| 
          
            
          
           | 
    @@ -135,7 +135,7 @@ author KN4CK3R <[email protected]> 1711702962 +0100 | |
| committer KN4CK3R <[email protected]> 1711702962 +0100 | ||
| encoding ISO-8859-1 | ||
| gpgsig -----BEGIN PGP SIGNATURE----- | ||
| <SPACE> | ||
| iQGzBAABCgAdFiEE9HRrbqvYxPT8PXbefPSEkrowAa8FAmYGg7IACgkQfPSEkrow | ||
| Aa9olwv+P0HhtCM6CRvlUmPaqswRsDPNR4i66xyXGiSxdI9V5oJL7HLiQIM7KrFR | ||
| gizKa2COiGtugv8fE+TKqXKaJx6uJUJEjaBd8E9Af9PrAzjWj+A84lU6/PgPS8hq | ||
| 
        
          
        
         | 
    @@ -150,7 +150,7 @@ gpgsig -----BEGIN PGP SIGNATURE----- | |
| -----END PGP SIGNATURE----- | ||
| 
     | 
||
| ISO-8859-1` | ||
| 
     | 
||
| commitString = strings.ReplaceAll(commitString, "<SPACE>", " ") | ||
| sha := &Sha1Hash{0xfe, 0xaf, 0x4b, 0xa6, 0xbc, 0x63, 0x5f, 0xec, 0x44, 0x2f, 0x46, 0xdd, 0xd4, 0x51, 0x24, 0x16, 0xec, 0x43, 0xc2, 0xc2} | ||
| gitRepo, err := openRepositoryWithDefaultContext(filepath.Join(testReposDir, "repo1_bare")) | ||
| assert.NoError(t, err) | ||
| 
          
            
          
           | 
    ||
      
      Oops, something went wrong.
        
    
  
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.