XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • None
    • None
    • None
    • Windows 10 x64
    • Our product teams collect and evaluate feedback from a number of different sources. To learn more about how we use customer feedback in the planning process, check out our new feature policy.

    Description

      In order to manage the permissions on the various repository and build a coherent application, we use submodules. With SourceTree we never have been able to properly manage the main repository because we do not have the permissions to all the repository so when we push the main repository, the push fails.

      This is very annoying.

      To bypass the problem, we use SourceTree to do git manipulation on the submodules but not on the main repository.

      For the main repository, we use the command lines with the following codes.
      // Script used to push

      #!/bin/sh
      # Stage everything.
      git add -A
      
      # Check is something need to be commited.
      if git diff --cached --exit-code &> /dev/null; then
        echo -e "\nNothing to commit"
      else
        # Working directory (RDE).
        wd=$(pwd)
      
        # Clear .msg file.
        > .msg
      
        # Fill .msg with commit messages from submodules.
        echo -e "\nGathering commit messages...\n"
      
        git submodule foreach --quiet "git log --pretty=format:'%s %n%n' origin/master..master >> '$wd/.msg'"
      
        # Store the content of .msg in a variable and delete the file.
        msg=$(cat .msg)
        rm .msg
      
        git commit --allow-empty -m "$msg"
      fi
      
      git push origin master --recurse-submodules=on-demand
      
      

      // Script used to pull

      #!/bin/sh
      
      # If true, update submodules even if RDE is up to date.
      force_update=false
      
      # Parse parameters.
      while getopts ":f" opt; do
        case $opt in
          f)
            echo -e "\nForce submodule update!\n" >&2
            force_update=true
            ;;
          \?)
            echo -e "\nInvalid option: -$OPTARG\n" >&2
            exit
            ;;
        esac
      done
      
      git fetch origin --recurse-submodules=on-demand && git fetch origin --tags
      
      state=$(git rebase origin/master)
      
      if ([ $? -eq 0 ] && [ "$state" != "Current branch master is up to date." ]) || [ "$force_update" = true ]; then
      	git submodule update && git submodule foreach "git --no-pager log --pretty=format:'%C(yellow)%h%Creset %s %C(cyan)<%an>%Creset' master..HEAD && git rebase HEAD master"
      	git status
      else
      	echo $state;
      fi
      

      Note: we do not initialize all the submodules otherwise when we update we get conflicts if we do not have any rights to the repository

      Attachments

        Activity

          People

            Unassigned Unassigned
            fb4e2ff6dcaf Martin Morin
            Votes:
            2 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: