By using this site, you agree to have cookies stored on your device, strictly for functional purposes, such as storing your session and preferences.

Dismiss

Fix pushing branch without commits

roundabout,
created on Monday, 4 December 2023, 18:20:50 (1701714050), received on Wednesday, 31 July 2024, 06:54:38 (1722408878)
Author identity: vlad <vlad.muntoiu@gmail.com>

977b8f0525dbce3673323e7c33c131ad04959e98

gitHTTP.py

@@ -62,12 +62,14 @@ def gitReceivePack(username, repository):

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    sha, time, identity, body = info.split("\n", 3)
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    login = flask.g.user
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                user = User.query.filter_by(username=login).first()
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                repo = Repo.query.filter_by(route=f"/{username}/{repository}").first()
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                commit = Commit(sha, user, repo, time, body, identity)
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                if not Commit.query.filter_by(identifier=f"/{username}/{repository}/{sha}").first():
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    user = User.query.filter_by(username=login).first()
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    repo = Repo.query.filter_by(route=f"/{username}/{repository}").first()
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                db.session.add(commit)
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                db.session.commit()
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    commit = Commit(sha, user, repo, time, body, identity)
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    db.session.add(commit)
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    db.session.commit()
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                return flask.Response(text, content_type="application/x-git-receive-pack-result")