gitdoc icon indicating copy to clipboard operation
gitdoc copied to clipboard

Commit/push/pull only applies to one repository

Open NorkzYT opened this issue 3 years ago • 4 comments

Hello @lostintangent and @mattferderer. Is there a way I can make the extension apply to more than one repository? Do I need to do something on my end or does the extension not have support for that?

NorkzYT avatar Jun 12 '22 14:06 NorkzYT

It currently only supports syncing with a single repo. Could you share a little more about what you have in mind, with syncing against multiple repos?

lostintangent avatar Jun 12 '22 16:06 lostintangent

My thoughts on how to implement this.

I was thinking about maybe editing the code a bit and at the begginning before the extension runs the following command:

git symbolic-ref --short HEAD

Ideas

  • We could maybe make it so that it runs the same commands that it has now to each terminal repository.
  • Have the extension detect all the Source Control Repositories.
  • Make the extension run the same commands on everything in the Source Control.

One of these could work and to add on, there could be an extension setting which would allow the user to define which repositories will be ignored by the extension.

I found this example: https://www.markusdosch.com/2020/07/git-auto-commit-push-every-couple-of-minutes/

I'm pretty sure this all could be scripted but I would like to use an extension instead.

NorkzYT avatar Jun 12 '22 17:06 NorkzYT

The stages that "Dean Whitehouse" listed is exactly what I want to do and I could probably just make a script and then an extension in the future.

https://raspberrypi.stackexchange.com/questions/14538/git-automatically-pull-commit-and-push

NorkzYT avatar Jun 12 '22 18:06 NorkzYT

@lostintangent My apologies for the terrible idea I had in mind.

I think it would be better to just edit your extensions code and somehow add support for the location the git commands will run at.

The reason I want the git commands to run in a certain location is so that all repositories in a certain folder will have the same commands executed for all of the ones the USER may have and not just execute on one repository as how it is now.

I can use a bash-script although I want to use a Vscode-Extension due to other reasons.

Here is my Bash script that works: (I changed some things due to privacy concerns.)

#!/bin/bash

echo "________________________________________________________________________________________"

# Git repositories location
cd /home/norkz/github       # (Executed with CRON(LiNUX) Automatically.) Change to folder where all github repositories are located at.

# store the current dir
CUR_DIR=$(pwd)

# Let the person running the script know what's going on.
echo "\n\033[1mPulling in latest changes for all repositories...\033[0m\n"

# Find all git repositories and update it to the master latest revision
for i in $(find . -name ".git" | cut -c 3-); do
    echo "";
    echo "\033[33m"+$i+"\033[0m";

    # We have to go to the .git parent directory to call the pull command
    cd "$i";
    cd ..;

    # finally pull, stage, commit and push.
                            
    git config --global credential.helper store --file=/home/norkz/github/REPOSITORY3/git/.git-credentials

    git config --global --add safe.directory /home/norkz/github/REPOSITORY1

    git config --global --add safe.directory /home/norkz/github/REPOSITORY2

    git config --global --add safe.directory /home/norkz/github/REPOSITORY3

    git config --global --add safe.directory /home/norkz/github/REPOSITORY4

    git config user.name "USER-NAME";

    git config user.email [email protected];

    git pull origin;

    sleep 1;

    git stage .;

    sleep 1;

    git commit -m "Auto Commit";

    sleep 1;

    git push origin;

    # lets get back to the CUR_DIR
    cd $CUR_DIR
done

echo "\n\033[32mComplete!\033[0m\n"

For example:

The "configuration" in package.json will have the following:

        },
        "gitdoc.runLocation": {
          "type": "string",
          "default": "C:/Users/USER/github.repositories.folder",
          "description": "Specifies the path where the extention will run the `git` commands in."
        },

This will be in between "gitdoc.autoCommitDelay" & "gitdoc.autoPull".

I'm still pretty new to TypeScript and I understand somethings for the most part so bare with me please.

I'm not sure how to exactly implement this, do you know of a way?

NorkzYT avatar Jun 17 '22 15:06 NorkzYT

Is it supposed to support multiple repo now ? Because I tried with 2 repos but it seems the second one is totally ignored image

Turtle4Man avatar May 07 '24 08:05 Turtle4Man