steps for launching
This commit is contained in:
@@ -756,6 +756,46 @@ def list_gitea_repos():
|
||||
except Exception as e:
|
||||
return jsonify({'message': f'Failed to list repositories: {str(e)}'}), 400
|
||||
|
||||
@admin_api.route('/list-gitea-branches', methods=['POST'])
|
||||
@csrf.exempt
|
||||
def list_gitea_branches():
|
||||
"""List branches from a Gitea repository"""
|
||||
data = request.get_json()
|
||||
if not data or 'url' not in data or 'token' not in data or 'repo' not in data:
|
||||
return jsonify({'message': 'Missing required fields'}), 400
|
||||
|
||||
try:
|
||||
# Try different authentication methods
|
||||
headers = {
|
||||
'Accept': 'application/json'
|
||||
}
|
||||
|
||||
# First try token in Authorization header
|
||||
headers['Authorization'] = f'token {data["token"]}'
|
||||
|
||||
# Get repository branches
|
||||
response = requests.get(
|
||||
f'{data["url"]}/api/v1/repos/{data["repo"]}/branches',
|
||||
headers=headers
|
||||
)
|
||||
|
||||
# If that fails, try token as query parameter
|
||||
if response.status_code != 200:
|
||||
response = requests.get(
|
||||
f'{data["url"]}/api/v1/repos/{data["repo"]}/branches?token={data["token"]}',
|
||||
headers={'Accept': 'application/json'}
|
||||
)
|
||||
|
||||
if response.status_code == 200:
|
||||
return jsonify({
|
||||
'branches': response.json()
|
||||
}), 200
|
||||
else:
|
||||
return jsonify({'message': f'Failed to list branches: {response.json().get("message", "Unknown error")}'}), 400
|
||||
|
||||
except Exception as e:
|
||||
return jsonify({'message': f'Failed to list branches: {str(e)}'}), 400
|
||||
|
||||
@admin_api.route('/list-gitlab-repos', methods=['POST'])
|
||||
@csrf.exempt
|
||||
def list_gitlab_repos():
|
||||
|
||||
Reference in New Issue
Block a user