-
Notifications
You must be signed in to change notification settings - Fork 899
add user agent functionality #1334
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
Conversation
I can see that it would probably be difficult to unit test this (unless we add some functionality to get the user agent in libgit2 - which we probably should do). I can add that, but in the meantime, I think that yes, sniffing in wireshark or fiddler would be good. Or at least stepping through in a debugger to make sure that things land in the native side correctly. I added a few notes regarding that, but I'm not sure that they're exhaustive, so I think that you should check to see how this is landing in the native side. |
/// </param> | ||
public static void SetUserAgent(ConfigurationLevel level, string userAgent) | ||
{ | ||
Proxy.git_libgit2_opts_set_user_agent(level, userAgent); |
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.
There's no ConfigurationLevel
for this call - it doesn't have anything to do with configuration. It only takes a user agent string and is applied to the entirety of the library.
This will be great to have, thanks for tackling this! |
Didn't know you could just use vargs without __listargs. The mono tracer is saying that it is entering and leaving the function:
The sample code is: using LibGit2Sharp;
class MainClass
{
public static void Main(string[] args)
{
GlobalSettings.SetUserAgent("txdv");
}
} I stepped with gdb through _opts (although without debugging symbols) and saw that the string "txdv" was duped, so I assume it did the right thing. Do you want me to implement the get functionality in libgit2? |
Also, do you want me to squash the whitespace fix into this same commit? |
Ok, I added OPT_GET_USER_AGENT libgit2 and implemented GetUserAgent in C# and it all works. I think though this should be a self contained commit, no need to add GetUserAgent here yet, since the functionality part of it gets shipped with vNext only anyway. On another note, how am I supposed to test new libgit2 functionality if all the binaries in the test directories get overwritten everytime I do a build? |
Great! 👍
Sure, I think that's reasonable.
libgit2 itself is included as part of the LibGit2Sharp.NativeBinaries package. There should be instructions there, but the basics are: clone the LibGit2Sharp.NativeBinaries package, update the libgit2 that you want to use, build that package and then you can set your nuget package to that. The very quick and dirty way, of course, is to overwrite the libgit2 source that's being copied. Quick and dirty, and mostly effective, but easy to mix oneself up. :) |
Ok, next question, if we are going to add GetUserAgent as well, shouldn't we use a getter/setter combo for this? public string UserAgent { get; set; } ? |
Sure, I think that's probably fits in nicely. :) |
I get a SIGSEGV running the libgit2sharp tests (master) with the newest libgit2 binary (master). I did however just overwrite LibGit2Sharp.Tests/bin/Release/lib/linux/x86_64/libgit2-381caf5.so with the newest compiled one. Don't know what to really do from here. I wrote my test, but can't check if it works correctly. AFAIK it is not really possible to run one specific test with xunit 1.9.2? |
That's not unexpected; it's likely that some function changed signatures between the version that LibGit2Sharp uses and the version that you compiled.
I don't know the command line. It is possible from Visual Studio Test Explorer. |
Is there a branch which is kept up to date? |
What ever happened with this? |
I'm not sure that I know what you're asking @mj1856 - this should be merged and working in a LibGit2Sharp in the last several years. Is something not working for you? |
It didn't get merged. It's not in the current shipping release anyway. |
@ethomson - to be clear, it appears the native functionality in libgit2 was merged, but this PR to expose it in libgit2sharp was closed without merging the code. There's no functionality in libgit2sharp to set the user agent. I could use that. |
the issue is described here #1333
Do I need to write some tests for this? Without being able to get the user agent(there is only set functionality in libgit2), I don't see how it is possible to write some feasible test.
Unless I create my own http server and issue a request and take a look at the the user agent information.