Important information: Google announced that, from September 2026, Android devices will require ALL apps to be signed by Google, effectively leading to an iOS situation. Value your right to a computer that does what you want; do not tolerate this monopolistic practice! Contact me if you don't understand why it is bad. Click to learn more.

Much more foolproof incoming commit parsing

by roundabout, Sunday, 24 March 2024, 19:15:40 (1711307740), pushed by roundabout, 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>