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

Much more foolproof incoming commit parsing

roundabout,
created on Sunday, 24 March 2024, 19:15:40 (1711307740), received on Wednesday, 31 July 2024, 06:54:42 (1722408882)
Author identity: vlad <vlad.muntoiu@gmail.com>

94c04599296e83b6dc7126684f863e8e18cad4f9

git_http.py

@@ -61,12 +61,17 @@ def git_receive_pack(username, repository):

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                if flask.request.data == b"0000":
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    return flask.Response("", content_type="application/x-git-receive-pack-result")
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            push_info = flask.request.data.split(b"\x00")[1].split(b" ")[0].decode()
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            old_sha, new_sha, _ = push_info.split()
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            push_info = flask.request.data.split(b"\x00")[0].decode()
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            print("REQUEST DATA")
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            print("------------")
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            print(flask.request.data)
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            if not push_info:
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                return flask.Response(text, content_type="application/x-git-receive-pack-result")
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            commits_list = subprocess.check_output(["git", "rev-list", f"{old_sha}..{new_sha}"], cwd=server_repo_location).decode().strip().split("\n")
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            old_sha, new_sha, _ = push_info[4:].split()         # discard first 4 characters, used for line length
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            sha = flask.request.data.split(b" ", 2)[1].decode()
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            commits_list = subprocess.check_output(["git", "rev-list", f"{old_sha}..{new_sha}"],
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                                   cwd=server_repo_location).decode().strip().split("\n")
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                for sha in commits_list:
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    info = git_command(server_repo_location, None, "show", "-s",
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        

@@ -145,4 +150,4 @@ def git_info_refs(username, repository):

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                response = flask.Response(text, content_type=f"application/x-git-{service}-advertisement")
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                response.headers["Cache-Control"] = "no-cache"
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            return response
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            return response
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                            
                                

templates/default.html

@@ -79,7 +79,7 @@

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                                    <iconify-icon icon="mdi:menu"></iconify-icon>
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                                </a>
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                                <ul>
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                <li><a href="/">{% trans %}roundabout{% endtrans %}</a></li>
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                <li><a href="/">{% trans %}roundabout{% endtrans %} (α)</a></li>
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                                    {% block breadcrumbs %}{% endblock %}
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                                </ul>
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                                <div class="flexible-space" id="navbar-separator"></div>