Hi Yasiru,

Following git commands are run by GoCD when it needs to update a git
material (with submodule) to a given revision (REVISION).

  git config remote.origin.url
  git rev-parse --abbrev-ref HEAD
  git fetch origin --prune
  git gc --auto
  git config --get-regexp ^submodule\..+\.url

  git clean -dff         *#In each submodule directory*
  git clean -dff
  git config --get-regexp ^submodule\..+\.url

  git config --remove-section submodule.NAME  *# For each submodule, named
NAME*
  git reset --hard
  git submodule foreach --recursive git checkout .
  git submodule init at
  git submodule sync at
  git submodule foreach --recursive git submodule sync
  git submodule update
  git submodule status
  git config --get-regexp ^submodule\..+\.url
  git clean -dff   *#In each submodule directory*
  git clean -dff

I found this article (
https://stackoverflow.com/questions/2155887/git-submodule-head-reference-is-not-a-tree-error)
which had similar issue with git submodules. would you mind trying it out
and see if that helps.

Regards,
Ankit



On Thu, Aug 2, 2018 at 12:12 PM Yasiru Kassapa <[email protected]> wrote:

> Hi Aravind thanks for the reply. I followed your instructions on my local
> machine on git 2.15.0. Following were my findings.
>
> 1.
>> git clone git://the-url some-dir
>> cd some-dir
>> git submodule update
>
>
> clones the repository but *git submodule update* doesn't update the
> submodule or output any content to console or return an error value.
>
> 2.
>> git clone git://the-url some-dir
>> cd some-dir
>> git submodule update --init
>
>
> clones the repository and *git submodule update --init* successfully
> clones the submodule and outputs the following:
>
> Submodule 'submodule' (https://gitrepourl.git) registered for path '
>> submodule'
>> Cloning into repopath/submodule'...
>> Submodule path 'submodule': checked out '<commit id>'
>
>
> Reading the git documentation for submodules
> <https://git-scm.com/docs/git-submodule> it seems that --init flag
> resolves the url for the submodule and adds an entry to it to the
> .git/config file in the repository and then  .
> Immediately after cloning a repository if i manually add the submodule
> entry to .git/config file git submodule update works.
>
> Should GoCD be running git submodule update --init instead of git
> submodule update when cloning a repository?
>
> Thanks again.
>
>
> On Thu, Aug 2, 2018 at 4:07 AM, Aravind SV <[email protected]>
> wrote:
>
>> Submodules should work. What happens if you do this locally:
>>
>> git clone git://the-url some-dir
>> cd some-dir
>> git submodule update
>>
>> Cheers,
>> Aravind
>>
>> On Wed, Aug 01, 2018 at 04:52:10 -0700, [email protected] wrote:
>> > Hi,
>> > I have a git repository with a single git submodule which goCD is not
>> able
>> > to clone. It gives the following error:
>> >
>> > pr|10:07:42.582 [GIT] Fetching changes
>> > > pr|10:07:42.886 [GIT] Performing git gc
>> > > pr|10:07:42.991 [GIT] Reset working directory pipelines/odoc-patient
>> > > pr|10:07:42.991 [GIT] Cleaning all unversioned files in working copy
>> > > pr|10:07:42.996 [GIT] Cleaning submodule configurations in .git/config
>> > > pr|10:07:42.997 [GIT] Updating working copy to revision
>> > > 7a54bc8dd6afa272d8c1dc793a4a7f871a500afa
>> > > pr|10:07:43.016 HEAD is now at 7a54bc8 Commit name
>> > > pr|10:07:43.016 [GIT] Removing modified files in submodules
>> > > pr|10:07:43.030 [GIT] Updating git sub-modules
>> > > &2|10:08:10.887 Error performing command: --- Command ---
>> > > &2|10:08:10.887 git submodule update
>> > > &2|10:08:10.887 --- Environment ---
>> > > &2|10:08:10.887 {}
>> > > &2|10:08:10.887 --- INPUT ----
>> > > &2|10:08:10.887
>> > > &2|10:08:10.887
>> > > &2|10:08:10.887 --OUTPUT ---
>> > > &2|10:08:10.887
>> > > &2|10:08:10.887 --- ERROR ---
>> > > &2|10:08:10.887 STDERR: Cloning into 'submodulename'...
>> > > &2|10:08:10.887 STDERR: fatal: reference is not a tree:
>> > > b79aacd45e81fadbb5a4f13009bd13f6a47d9958
>> > > &2|10:08:10.887 STDERR: Unable to checkout
>> > > 'b79aacd45e81fadbb5a4f13009bd13f6a47d9958' in submodule path
>> 'submodulename'
>> > > &2|10:08:10.887 ---
>> > > &2|10:08:10.887
>> > > ex|10:08:10.896 [go] Job completed
>> odoc-patient/1/debugApk/1/defaultJob on
>> > > ip [/home/ubuntu/soft/go-agent-17.10.0]
>> >
>> >
>> >  Is this a known issue or is there any workaround for submodules in
>> goCD?
>> >
>> > Thanks a lot.
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups "go-cd" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> an email to [email protected].
>> > For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "go-cd" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "go-cd" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"go-cd" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to