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

Change default branch

roundabout,
created on Friday, 26 April 2024, 11:55:56 (1714132556), received on Wednesday, 31 July 2024, 06:54:46 (1722408886)
Author identity: vlad <vlad.muntoiu@gmail.com>

ee71af38280abcdfb01f9af56f8294632ba815cc

app.py

@@ -1455,8 +1455,11 @@ def repository_settings(username, repository):

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                if get_permission_level(flask.session.get("username"), username, repository) != 2:
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    flask.abort(401)
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            repo = git.Repo(os.path.join(config.REPOS_PATH, username, repository))
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                return flask.render_template("repo-settings.html", username=username, repository=repository,
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                         repo_data=db.session.get(Repo, f"/{username}/{repository}"))
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                         repo_data=db.session.get(Repo, f"/{username}/{repository}"),
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                         branches=[branch.name for branch in repo.branches])
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            @repositories.route("/<username>/<repository>/settings/", methods=["POST"])
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        

@@ -1468,6 +1471,9 @@ def repository_settings_post(username, repository):

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                repo.visibility = flask.request.form.get("visibility", type=int)
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                repo.info = flask.request.form.get("description")
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            print(flask.request.form.get("default_branch"))
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            repo.default_branch = flask.request.form.get("default_branch")
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            print(repo.default_branch)
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                db.session.commit()
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                            
                                

doc/internal/Style guide.md

templates/repository/repo-settings.html

@@ -31,6 +31,16 @@

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                                            <label for="description">{% trans %}Description{% endtrans %}</label>
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                                            <textarea id="description" name="description" rows="4">{% if repo_data.info %}{{ repo_data.info }}{% endif %}</textarea>
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                                        </x-vbox>
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                    <x-vbox class="nopad">
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                        <label for="default-branch">{% trans %}Default branch{% endtrans %}</label>
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                        <select id="default-branch" name="default_branch">
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                            {% for branch in branches %}
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                                <option value="{{ branch }}" {% if branch == repo_data.default_branch %}selected{% endif %}>{{ branch }}</option>
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                            {% endfor %}
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                        </select>
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                        {% trans %}This is the branch the application will redirect to automatically if one is not specified.
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        Note that only branch names are supported, not other references like tags or commit hashes.{% endtrans %}
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                    </x-vbox>
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                                        <button type="submit">Update</button>
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                                    </x-vbox>
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                                </form>