Hi Robert, Drone uses the netrc to authenticate with GitHub, Bitbucket, GitLab and Gogs. I can confirm, as a Drone+Gogs user myself, that netrc authentication to private Gogs repositories works very well. It does not require manually editing the database.
There are a few different reasons, however, that you might get this error message. I have detailed these issues below:
If you are using an older version of Gogs. There have been at least 2 major Gogs releases where the ability to authenticate with a Netrc was broken, and later fixed (see https://github.com/gogits/gogs/issues/2721).
If your repository is public (any Gogs user can view) but Gogs is running in private mode (you need to have a Gogs username and password to view public repositories). In this case you need to set GOGS_PRIVATE_MODE per the installation instructions. When you activate the repository in Drone it will be treated as private, and credentials will be used to clone. IMPORTANT you need to enable private mode before first use. You cannot set this value after you have started using drone.
If you added the repository to Drone and the repository was public, but then it was changed in Gogs to private. Drone will continue to think it is public and will not attempt to authenticate with credentials when cloning.
If you are attempting to connect to Gogs using an IP address or custom hostname that is not accessible from inside a Docker container. This typically happens when someone tries to use a custom Docker hostname or localhost or loopback network address to access Gogs from inside the Drone container. This does not seem to be an issue for you, though, based on your test above.
If you activate the repository with a user account, and then either delete that user account or revoke Drone’s access to that user account. This would cause problems because Drone will use this user’s oauth token in the netrc file to authenticate the git clone.
These are (off the top of my head) some of the common root causes for this issue.
I was facing the third issue which is similar for Gitea. I have public repo but when I have changed to private then I go fatal: could not read Username for.... So what should be the workaround for if I want to keep private the repo now?
Drone does not authenticate when cloning a public repository. If you changed your repository from public to private you need to re-sync your account so that Drone can be made aware of this change and update its internal information, and in turn start authenticating when cloning.