-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1159 create mirror of private GitHub repository #1161
1159 create mirror of private GitHub repository #1161
Conversation
end | ||
end | ||
|
||
class SourceTypeValidator < ActiveModel::Validator | ||
def validate(record) | ||
if record.mirror? && !record.source_type.present? | ||
record.errors[:source_address] = "not a valid remote repository (types supported: #{SOURCE_TYPES.join(', ')})" | ||
record.errors[:source_address] = "not a valid remote repository or not accessible (types supported: #{SOURCE_TYPES.join(', ')})" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [136/80]
6db3ea7
to
aa516e2
Compare
Other possibilities to take a look at include
|
Not sure, what you are trying to accomplish, but "command ...| tee file" could be a posix conform aka *x compatible thing you are looking for. |
The thing is, that |
Hmmm, but So the only thing what would explain that, is IMHO, that the related fds get closed on exec - possible, but I doubt that. Have you a conrete working snippet, which I can use for playing around ...? |
"neither stdout nor stderr" here means the usual practice of many commands that the password prompt is directly sent to the tty, bypassing stdout/stderr and any redirections of these. Commands like |
You can directly try FYI: I used I successfully tried |
What about abusing GIT_ASKPSS? E.g.:
Fore more see http://code.metager.de/source/xref/git/prompt.c#44 ;-) |
The script as you posted does not work for me. However, it's a very good pointer to This does exactly what I'm looking for (because we don't want to use credentials at this point):
|
2a2bd54
to
9dc3212
Compare
Now the pull request is ready for review. In my opinion, it's a fix for the problem and not a workaround anymore. |
elsif GitRepository.is_svn_repository?(source_address) | ||
self.source_type = 'svn' | ||
if source_address? | ||
if GitRepository.is_git_repository?(source_address) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could do the following instead:
self.source_type =
if GitRepository.is_git_repository?(source_address)
'git'
....
I ignore the hound comments after the last commit because they don't match to our style guide (and hound has the hiccups). |
f54192f
to
6370334
Compare
👍 |
…ithub_repository 1159 create mirror of private GitHub repository
Updated message
This fixes #1159 and a few other git/cloning related bugs (see first commits).
When a private git repository is supposed to be cloned, git usually asks for credentials. This prompt is prevented by asking
/bin/true
for them. Of course,true
doesn't supply any, but exits with codeSUCCESS
, so git thinks they are supplied and fails because the credentials don't fit to the repository.I removed the previous workaround-commits by rebase (see original message).
Original message
This is more of a workaround than a fix for #1159.
I don't see any fast way to check if something is a git repository than
git ls-remote
. However, this asks for credentials when calling it on a github private repository.I tried to read the login prompt of
git ls-remote
inSubprocess.run
, but I could not get my hands on the prompt lines. Neither withIO.popen
nor withOpen3.popen2e
.The best solution would be to read those login prompt lines and abort if they are present, but I can't figure out how to do this, because they are not printed to stdout nor stderr of the child process.