task icon indicating copy to clipboard operation
task copied to clipboard

feat(remote): support include git remote

Open vmaerten opened this issue 1 year ago • 12 comments

I've work on add the support of Git in the remote experimentation. I've used the go-git package, which is Git implementation in pure go. I've also used git-urls to help me to parse all URLs.

Some informations :

  • I did not handle the custom timeout for now
  • We support SCP / SSH / HTTPS URL
  • It seems that SSH takes more time than HTTPS
  • Git remote entrypoint (--taskfile) works
  • include local -> remote -> remote:local works

I'll work next on perf optimisation. I've in mind to mutualise git clone to avoid cloning multiple times the same repo.

I've added tests. I'll add test of node_http in another PR.

EDIT : The link with to the preview

vmaerten avatar May 11 '24 13:05 vmaerten

I've tested it and a friend also tested it. I am open to gather feedback on it :)

vmaerten avatar May 11 '24 13:05 vmaerten

@vmaerten Thanks for working on this! This is a very popular request. I will definitely give this a go in the next couple of days. Finally some nice weather in the UK, so I'll be out enjoying the sun as much as possible this weekend! 🌞

It might be worth putting a message on the remote experiment issue so that people who are subscribed over there can try it too. I have updated the OP there to link back here.

pd93 avatar May 11 '24 13:05 pd93

I really enjoy working on Task. Let me know if you have questions regarding my implementation Sure, enjoy the sun, I did the same this weekend in France! :slightly_smiling_face:

Good idea! I've just done it :slightly_smiling_face:

vmaerten avatar May 12 '24 18:05 vmaerten

@blackjid 's comment :

That is awesome @vmaerten thank for the work...

Why did you choose to set the filename and the git reference in the same querystring in the url? Why not just having a different querystring for the filename? https://github.com/foo/bar.git?ref=main&filename=directory/Taskfile.yml

Or if you don't want the extra query string, a more readable form I think could be to add the path to the file just after the .git https://github.com/foo/bar.git/directory/Taskfile.yml?ref=main maybe with a double slash // like terraform and others does.. https://github.com/foo/bar.git//directory/Taskfile.yml?ref=main

Sorry if this is not the place or time to give feedback. Maybe discord?

First of all, thanks for the feedback. To be honest, I did not find a consensus for this kind of URL in the community, so I took the example URL in the issue (here)

Following your propostions, I like the one with the query param representing the filename. In the other hand, if the community already knows the "terraform" format, it could be good to adopt it.

Let's discuss with @pd93 and @andreynering

vmaerten avatar May 14 '24 16:05 vmaerten

Hi,

I find this work awesome ! Just wanted to mention that I've been able to run this on my side using http over public repo, private repo using token auth and ssh. All behaved as expected.

This, added to the remote file feature will definitely help saving a tremendous amount of time sharing and managing taskfiles. I'm really excited to have this available in a few.

Thanks for this work.

adlnc avatar Jun 01 '24 18:06 adlnc

Thanks for checking this! We will definitely move forward on this!

vmaerten avatar Jun 03 '24 09:06 vmaerten

Any update ?

jylenhofdecat avatar Jun 17 '24 08:06 jylenhofdecat

I need to rebase due to recent merged PR I will do it

vmaerten avatar Jun 28 '24 16:06 vmaerten

@pd93 I've rebased to add the function for prefixing the cache (done here: https://github.com/go-task/task/pull/1636). I've also taken your review into account. For some reason, the CI is not triggered. :'(

vmaerten avatar Jun 28 '24 17:06 vmaerten

What am I doing wrong?

$ export TASK_X_REMOTE_TASKFILES=1
$ task --list --taskfile [email protected]/$ORGANIZATION/$REPO?ref=main//taskfile.yml
stat [email protected]/$ORGANIZATION/$REPO?ref=main//taskfile.yml: no such file or directory

The following code shows that the org, repo, and file exists ...

$ git clone [email protected]:$ORGANIZATION/$REPO.git --branch main && cp $REPO/taskfile.yml .

oliver-helix avatar Jul 30 '24 16:07 oliver-helix

~~For now, you need to put the schema in front of the URL. Either ssh://[email protected]/foo/bar.git?ref=main//directory/Taskfile.yml or https://github.com/foo/bar.git?ref=main//directory/Taskfile.yml I'll impletement later the URL without the scheme~~

EDIT: like you use the URL for git clone : [email protected]:foo/bar.git?ref=main//directory/Taskfile.yml this works.

vmaerten avatar Jul 31 '24 17:07 vmaerten

@blackjid & @pd93 Following this comment : https://github.com/go-task/task/pull/1652#discussion_r1659114619 I've changed the url to be go-getter compatible. I've also put the ref optional, default to the default branch

vmaerten avatar Aug 12 '24 19:08 vmaerten

what do you think about this? https://github.com/go-task/task/pull/1774 clearly there is need to something...

blackjid avatar Sep 24 '24 17:09 blackjid

@blackjid I've merged this one to move forward on this feature

Let's talk about go-getter or not, in the remote issue or the PR

vmaerten avatar Sep 24 '24 17:09 vmaerten