Response from proc:execute() for git Command Not Coming Through as Expected

Friday, 21 January 2022 · 4 messages · last reply 22 Jan 2022
EK
Eliot Kimber21 Jan 2022 20:27 #
[BaseX 9.6.4 on Mac through BaseX GUI] I’m trying to automate syncing a database with content from a git repo that is locally cloned. My approach is to use proc:exec() to pull the repo and then use git diff-tree to see what files changed:
let $pullResult := proc:execute($gitCmd,('pull', '-v'), map{'dir' : $repoPath})
let $changeList := proc:execute($gitCmd, ('diff-tree', '--no-commit-id', '--name-status', 'HEAD'), map{'dir' : $repoPath})
However, the result returned for “diff-tree” appears to get truncated. Here’s a typical result, where I’m echoing out the $pullResult and $changeList values created above: Pull result: <result> <output>Already up to date. </output> <error>From code.devsnc.com:doc/dita-now = [up to date] master -&gt; origin/master = [up to date] dita-now -&gt; origin/dita-now = [up to date] rtprn -&gt; origin/rtprn = [up to date] sanfransokyo -&gt; origin/sanfransokyo = [up to date] scodefreeze -&gt; origin/scodefreeze = [up to date] scratc/table_issues_fix -&gt; origin/scratc/table_issues_fix = [up to date] scratch/fix_canvas_issue -&gt; origin/scratch/fix_canvas_issue = [up to date] scratch/newDitavals2022 -&gt; origin/scratch/newDitavals2022 = [up to date] scratch/simplifyDitavals -&gt; origin/scratch/simplifyDitavals = [up to date] scratch/table_name_issue -&gt; origin/scratch/table_name_issue </error> <code>0</code> </result> Change list: <result> <output>M doc </output> <code>0</code> </result> Note that the pull response looks as expected but the change list response is just “M\tdoc” where “doc” is the first directory in what should be a path to a file. Here’s the same result from the command line: dita-now % git diff-tree --no-commit-id --name-status -r HEAD M doc/source/product/rpa-studio/task/use-datareader-queryexcel.dita M doc/source/product/rpa-studio/task/use-datetime-add.dita M doc/source/product/rpa-studio/task/use-datetime-compare.dita … I can’t see anything I’m doing wrong or options to the execute() or system() functions that would affect the result. Any idea what might be causing this or how I could work around it? Thanks, Eliot _____________________________________________ Eliot Kimber Sr Staff Content Engineer O: 512 554 9368 M: 512 554 9368 servicenow.com<https://www.servicenow.com> LinkedIn<https://www.linkedin.com/company/servicenow> | Twitter<https://twitter.com/servicenow> | YouTube<https://www.youtube.com/user/servicenowinc> | Facebook<https://www.facebook.com/servicenow>
IL
Imsieke, Gerrit, le-tex22 Jan 2022 08:35 #
Hi Eliot, Maybe the pager is getting in your way? Try the global git option --no-pager. Gerrit
Quoted text · Eliot Kimber · 98 lines
On 21.01.2022 20:27, Eliot Kimber wrote: > [BaseX 9.6.4 on Mac through BaseX GUI] > > I’m trying to automate syncing a database with content from a git repo > that is locally cloned. > > My approach is to use proc:exec() to pull the repo and then use git > diff-tree to see what files changed: > > let $pullResult := proc:execute($gitCmd,('pull', '-v'), map{'dir' : > $repoPath}) > > let $changeList := proc:execute($gitCmd, ('diff-tree', '--no-commit-id', > '--name-status', 'HEAD'), map{'dir' : $repoPath}) > > However, the result returned for “diff-tree” appears to get truncated. > > Here’s a typical result, where I’m echoing out the $pullResult and > $changeList values created above: > > Pull result: > > <result> > > <output>Already up to date. > > </output> > > <error>From code.devsnc.com:doc/dita-now > > = [up to date] master -&gt; origin/master > > = [up to date] dita-now -&gt; origin/dita-now > > = [up to date] rtprn -&gt; origin/rtprn > > = [up to date] sanfransokyo -&gt; origin/sanfransokyo > > = [up to date] scodefreeze -&gt; origin/scodefreeze > > = [up to date] scratc/table_issues_fix -&gt; > origin/scratc/table_issues_fix > > = [up to date] scratch/fix_canvas_issue -&gt; > origin/scratch/fix_canvas_issue > > = [up to date] scratch/newDitavals2022 -&gt; > origin/scratch/newDitavals2022 > > = [up to date] scratch/simplifyDitavals -&gt; > origin/scratch/simplifyDitavals > > = [up to date] scratch/table_name_issue -&gt; > origin/scratch/table_name_issue > > </error> > > <code>0</code> > > </result> > > Change list: > > <result> > > <output>M doc > > </output> > > <code>0</code> > > </result> > > Note that the pull response looks as expected but the change list > response is just “M\tdoc” where “doc” is the first directory in what > should be a path to a file. > > Here’s the same result from the command line: > > dita-now % git diff-tree --no-commit-id --name-status -r HEAD > > Mdoc/source/product/rpa-studio/task/use-datareader-queryexcel.dita > > Mdoc/source/product/rpa-studio/task/use-datetime-add.dita > > Mdoc/source/product/rpa-studio/task/use-datetime-compare.dita > > … > > I can’t see anything I’m doing wrong or options to the execute() or > system() functions that would affect the result. > > Any idea what might be causing this or how I could work around it? > > Thanks, > > Eliot >
CG
Christian Grünin reply to Eliot Kimber, 21 Jan 2022, 20:2722 Jan 2022 12:08 #
Quoted text · Eliot Kimber · 3 lines
> let $changeList := proc:execute($gitCmd, ('diff-tree', '--no-commit-id', '--name-status', 'HEAD'), map{'dir' : $repoPath}) > > dita-now % git diff-tree --no-commit-id --name-status -r HEAD
That’d probably be too simple, but didn’t you forget '-r' in your XQuery function call?
EK
Eliot Kimberin reply to Imsieke, Gerrit, le-tex, 22 Jan 2022, 08:3522 Jan 2022 16:54 #
Gerrit, It looks like –no-pager is not a git option for the version I’m using under macOS but I would expect it to know it’s not in a terminal and therefore not do any paging or coloring, which appears to be the case. I do have it working now, so I can keep my database in sync with a git repo fairly efficiently. Cheers, E. _____________________________________________ Eliot Kimber Sr Staff Content Engineer O: 512 554 9368 M: 512 554 9368 servicenow.com<https://www.servicenow.com> LinkedIn<https://www.linkedin.com/company/servicenow> | Twitter<https://twitter.com/servicenow> | YouTube<https://www.youtube.com/user/servicenowinc> | Facebook<https://www.facebook.com/servicenow>
Quoted text · BaseX-Talk · 107 lines
From: BaseX-Talk <basex-talk-bounces at mailman.uni-konstanz.de> on behalf of Imsieke, Gerrit, le-tex <gerrit.imsieke at le-tex.de> Date: Saturday, January 22, 2022 at 1:36 AM To: basex-talk at mailman.uni-konstanz.de <basex-talk at mailman.uni-konstanz.de> Subject: Re: [basex-talk] Response from proc:execute() for git Command Not Coming Through as Expected [External Email] Hi Eliot, Maybe the pager is getting in your way? Try the global git option --no-pager. Gerrit On 21.01.2022 20:27, Eliot Kimber wrote: > [BaseX 9.6.4 on Mac through BaseX GUI] > > I’m trying to automate syncing a database with content from a git repo > that is locally cloned. > > My approach is to use proc:exec() to pull the repo and then use git > diff-tree to see what files changed: > > let $pullResult := proc:execute($gitCmd,('pull', '-v'), map{'dir' : > $repoPath}) > > let $changeList := proc:execute($gitCmd, ('diff-tree', '--no-commit-id', > '--name-status', 'HEAD'), map{'dir' : $repoPath}) > > However, the result returned for “diff-tree” appears to get truncated. > > Here’s a typical result, where I’m echoing out the $pullResult and > $changeList values created above: > > Pull result: > > <result> > > <output>Already up to date. > > </output> > > <error>From code.devsnc.com:doc/dita-now > > = [up to date] master -&gt; origin/master > > = [up to date] dita-now -&gt; origin/dita-now > > = [up to date] rtprn -&gt; origin/rtprn > > = [up to date] sanfransokyo -&gt; origin/sanfransokyo > > = [up to date] scodefreeze -&gt; origin/scodefreeze > > = [up to date] scratc/table_issues_fix -&gt; > origin/scratc/table_issues_fix > > = [up to date] scratch/fix_canvas_issue -&gt; > origin/scratch/fix_canvas_issue > > = [up to date] scratch/newDitavals2022 -&gt; > origin/scratch/newDitavals2022 > > = [up to date] scratch/simplifyDitavals -&gt; > origin/scratch/simplifyDitavals > > = [up to date] scratch/table_name_issue -&gt; > origin/scratch/table_name_issue > > </error> > > <code>0</code> > > </result> > > Change list: > > <result> > > <output>M doc > > </output> > > <code>0</code> > > </result> > > Note that the pull response looks as expected but the change list > response is just “M\tdoc” where “doc” is the first directory in what > should be a path to a file. > > Here’s the same result from the command line: > > dita-now % git diff-tree --no-commit-id --name-status -r HEAD > > Mdoc/source/product/rpa-studio/task/use-datareader-queryexcel.dita > > Mdoc/source/product/rpa-studio/task/use-datetime-add.dita > > Mdoc/source/product/rpa-studio/task/use-datetime-compare.dita > > … > > I can’t see anything I’m doing wrong or options to the execute() or > system() functions that would affect the result. > > Any idea what might be causing this or how I could work around it? > > Thanks, > > Eliot >

⚡Generated with XQuery