go-gitea / gitea

Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD
https://gitea.com
MIT License
45.1k stars 5.49k forks source link

Store access token for migration #29286

Open Kirill opened 8 months ago

Kirill commented 8 months ago

Feature Description

I up local version of gitea for store (and sync) some interesting repositories from gitlab, guthub, etc... Each time when I want create migration, I must put access token. Why you can't store my access token? image

Screenshots

In gitlab I can create auth token witch stored and I don't set it each time image

OPerepadia commented 2 months ago

I have the same use case. It would be really convenient to store an access token and not have to enter it every time a new migration is added. Additionally, it would be great if we could update the token when it expires, rather than having to delete and re-add every affected repository again. EDIT: It turns out that it's already possible to update the access token without deleting and cloning every repository. You need to go to your repository settings, and under Mirror Settings, there is Authorization section where you can paste the new token in a Password field (see below image). It's a bit confusing that they call it a password though, because when you add a new migration, they still refer to it as an Access Token. image

tobiashochguertel commented 4 days ago

I had the same need, and solved it for the moment with Chrome / Firefox Extension Tapermonkey (http://tampermonkey.net/) with the following UserScript for Tampermonkey written in JavaScript:

// ==UserScript==
// @name         gitea-migrate-from-github-autofill
// @namespace    http://tampermonkey.net/
// @version      2024-11-10
// @description  try to take over the world!
// @author       You
// @match        https://gitea.hochguertel.work/repo/migrate*
// @icon         https://about.gitea.com/gitea-text.svg
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    console.log('Tampermonkey added `gitea-migrate-from-github-autofill` script.');

    document.getElementById('auth_token').value = "github_pat_....";
    document.getElementById('mirror').click();
    document.getElementById('lfs').click();
    document.querySelector('input[name="wiki"]').click();
    document.querySelector('input[name="labels"]').click();
    document.querySelector('input[name="issues"]').click();
    document.querySelector('input[name="pull_requests"]').click();
    document.querySelector('input[name="releases"]').click();
    document.querySelector('input[name="milestones"]').click();

})();

Important is the line // @match https://gitea.hochguertel.work/repo/migrate*, with that, you define where this UserScript will be activated.

Have a look in the Tampermonkey Documentation about the property match.