-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Adjusting SVN commands to consider the @ symbol #4551
Conversation
end | ||
|
||
def svn_cached_location | ||
escape(cached_location) |
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.
Just use escape(cached_location)
everywhere instead of svn_cached_location
.
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.
Also this should be reused for the unpack strategy.
end | ||
|
||
private | ||
|
||
def escape(svn_url) |
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.
Should this be a URL or a path?
args << target | ||
target_arg = target.to_s | ||
target_arg = escape(target_arg) if svncommand == "up" | ||
args << target_arg |
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.
Can you reorder this a bit? Currently we have to check twice for target.directory?
and once for svncommand == "up"
, which all check for the same thing.
Hi @reitermarkus, done!
|
Thanks for the detailed and great first PR! CC @apjanke for thoughts on this as he'd worked on similar recently. |
args << target | ||
elsif svncommand == "update" | ||
args << svn_escape(target) | ||
end |
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.
It's still checking for the same thing twice. Make this
args = if target.directory?
["svn", "update", svn_escape(target)]
else
["svn", "checkout", url, target]
end
That make me think: Is svn update target
the same as cd target; svn update
?
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.
(args)
Oh, that's indeed way better. I didn't see it and I'm blaming my lack of ruby skills! ;-)
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.
@reitermarkus , about the cd target
Yes, the effect of cd target@peg; svn update
is the same as svn update target@peg@
- to the repository, at least.
I thought of that but as I was not sure if or how brew could get affected to these path changes, I kept with this "maybe more conservative approach". As per your comment I looked a bit further and decided to give it a try.
So the export command ended up like this and worked fine (thanks to the chdir
).
system_command! "svn",
args: ["export", "--force", ".", unpack_dir],
chdir: path.to_s
The update looked like this and it worked (note: no output is read from it).
args = if target.directory?
["cd", target.to_s, ";", "svn", "update"]
else
["svn", "checkout", url, target]
end
However, I could not make the svn info
work with popen_read
. It's used by the methods last_commit
, repo_url
and source_modified_time
. Looks like popen_read
keeps returning the output of the first command (cd).
Tried this:
xml = REXML::Document.new(Utils.popen_read("cd", cached_location.to_s, ";", "svn", "info", "--xml"))
and even tried with &> /dev/null
:
xml = REXML::Document.new(Utils.popen_read("cd", cached_location.to_s, "&> /dev/null;", "svn", "info", "--xml"))
In the end, even if we manage to get past this problem in svn info
, I think the svn_escape() is easier to read and may be easier to understand in the future.
One option would be bringing svn_escape() back to download_strategy
and using it only there, leaving the export command with the chdir.
What do you think?
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.
Instead of popen_read
you can also use system_command
. It returns a result which you can call stdout
on.
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.
I didn't test with system_command
yet, but do you think this is better?
# with svn_escape
xml = REXML::Document.new(Utils.popen_read( "svn", "info", "--xml", svn_escape(cached_location)))
...
# so far, with system_command, cd ..; & .stdout
xml = REXML::Document.new(system_command("cd", cached_location.to_s, ";", "svn", "info", "--xml").stdout)
To me it seems less obscure using svn_escape
... and there's the possibility that more adjustments might have to be done (as it didn't work already with popen_read
).
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.
info = system_command("svn", args: ["info", "--xml"], chdir: cached_location)
.stdout
xml = REXML::Document.new(info)
OK, @reitermarkus, please check latest changes, I've tested and it's working.
Which works, but the output of |
args << url unless target.directory? | ||
args << target | ||
args = if target.directory? | ||
["cd", target.to_s, ";", "svn", "update"] |
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.
This also needs to use system_command!
with chdir:
.
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.
That's what I meant with my last comment, I wanted to check because of the
check if args[0] == "update"
...
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.
One last change, then I think this is good to go.
if revision | ||
ohai "Checking out #{@ref}" | ||
args << "-r" << revision | ||
end | ||
args << "--ignore-externals" if ignore_externals | ||
safe_system(*args) | ||
if args[0] == "update" |
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.
Make this target.directory?
.
args = ["svn", svncommand] | ||
args << url unless target.directory? | ||
args << target | ||
args = target.directory? ? ["update"] : ["checkout", url, target] |
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.
Make this an empty array and insert the args
from here below like this.
system_command("svn", args: ["update", *args], chdir: target.to_s)
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.
done!
Thanks, @ffeu, great work! |
Sorry for the slow reply; I've been traveling. This looks like a good approach to me. |
brew style
with your changes locally?brew tests
with your changes locally?Details
This is another approach to solve problem presented by the #4358 PR.
Subversion uses '@' to point to a specific revision, so when creating formulas with an @ symbol, the local svn path inherits that character and Subversion gets confused.
Basically, an additional @ at the end solves it. So no need to change the paths, it's justing changing the commands.
However, this is not consistent through all commands. The commands are affected as follows:
As previously discussed in the #4358 PR, this approach:
brew style
is OK with my changes, but there were warnings unrelated to this PR.Disclaimer
I kindly request special attention reviewing this PR, as my ruby experience is equal to 28 lines of code (this PR). :)