GithubHelp home page GithubHelp logo

alibaba / git-repo-go Goto Github PK

View Code? Open in Web Editor NEW
244.0 11.0 56.0 1.12 MB

git-repo is a command-line tool for centralized workflow, can work with Gerrit, AGit-Flow compatible servers. It is written in Golang, and it can be installed easily without further dependency. It provides an easy-to-use solution for multiple repositories which is introduced by Android repo first, and it can also work with a single repository.

Home Page: https://git-repo.info/

License: Apache License 2.0

Makefile 1.95% Shell 48.61% Go 44.68% Perl 3.42% Python 1.34%
agit-flow git-repo

git-repo-go's Introduction

Build Status

git-repo

repo reimplemented in Golang and many others

git-repo is repo reimplemented in Golang and with many other features. Using git-repo, a developer can create code reviews (pull requests) from client side directly. There will be no fork, no feature branches, and no write permission needed.

git-repo is a command line tool, which adds more sub-commands to git, and works for centralized git workflow like Gerrit, agit-flow of Alibaba.com, and other agit-flow alike protocols...

Installation

Download or compile the binary of git-repo from this repository, and install (copy) the executable of git-repo to proper location, such as /usr/bin of Linux and MacOS, and C:\Windows\system32 of Windows.

After installation, execute the following command to validate the installation:

git repo version

Git aliases installed from git-repo

git-repo installs some useful git configurations for user, some unique alias commands are:

git peer-review => git repo upload --single
git pr => git repo upload --single
git download => git repo download --single

Single repository mode

Create code-review directly from client side

  1. Clone a repository

     git clone https://codeup.teambition.com/gotgit/demo.git
    
  2. Create a local branch (optional)

     git checkout -b some/topic origin/master
    
  3. Create commits in worktree...

  4. Create code-review from command line:

     git pr
    

There are many options for git pr (or git peer-review, or git review), please check the manual:

    git repo upload --help

Download code-review to local repository for review

A new code-review (pull request) will be created or a old code-review will be refreshed after running git pr. Each code-review has a unique number, such as pull request #123.

Reviewer can download it using command

git download 123

, and make a code review in local worktree.

Update code-review

Repeated command by author will update the code review:

git pr

If a reviewer wants to update a code-review, he or she can run:

git pr --change 123

(suppose 123 is the code review ID, the reviewer just downloaded)

Multiple repositories

git-repo supports android style multiple repositories management.

  • Init workspace from a manifest project.

      git repo init <manifest-url>
    
  • Clone / update all repositories referenced in the manifest repository.

      git repo sync
    
  • Create a local working branch instead of detached HEAD on all repositories.

      git repo start --all some/topic
    
  • Send changes to remote server to create code reviews.

      git repo upload
    

git-repo-go's People

Contributors

0xd219b avatar 1216114309zpf avatar dyrone avatar guestliu avatar jiangxin avatar ratmice avatar speedoops avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

git-repo-go's Issues

支持的GIT仓库列表说明

建议列举支持的GIT仓库清单。

只在codeup的文档里看到说:

git-repo 可以支持 AGit-Flow 兼容的代码平台以及 Gerrit。

具体的有哪些?github、gitlab、gitee这些能支持吗?

git repo upload 404?

git repo upload
WARNING: You are suggested to install or upgrade git to version 2.10.0 or above
* The git-interpret-trailers command introduced in git 2.2.0 is used for the Gerrit commit-msg hook.
* sending custom HTTP headers is only supported in git 2.9.0 and above
* Some review options are sent using git push-options which are available in git 2.10.0 and above.
ERROR: 404: bad ssh_info response of 'https://xxxx/ssh_info'
Error: fail to load remotes: origin

git repo sync ERROR: bad address for review ''

Hi, Thanks for bring up such a great tool.

What's the problem?

ADE@2-vt0003 MINGW64 /d/CodeBase/AOSP
$ git repo sync
NOTE: fail to check remote server, you may need to install gerrit hooks by hands
ERROR: bad address for review ''

ADE@2-vt0003 MINGW64 /d/CodeBase/AOSP
$ git repo sync
NOTE: fail to check remote server, you may need to install gerrit hooks by hands
ERROR: bad address for review ''
FATAL: fail to rename lockfile to 'D:\CodeBase\AOSP.repo\project.list': rename D:\CodeBase\AOSP.repo\project.list.lock D:\CodeBase\AOSP.repo\project.list: Access is denied.

What did I do?

  1. I copy git-repo.exe to my local executable path (i.e. C:\Program Files\Git\mingw64\bin\git-repo.exe), then it's ok to run git repo version;
    $ git repo version
    git-repo version 0.7.4
    git version 2.24.1.windows.2

  2. I create a repo manifest project, and edit the default.xml to add sub git projects.

  3. I use git repo init -u <my-manifest-project-url to init the repo.

  4. git repo sync, so far so good.

  5. git repo pr, after this, whenever i execute git repo sync again, it shows the above erros.

Need help:

  1. Did I miss some step to use this git-repo tool? What should I do to fix this?
  2. It seems a little complicate to modify gitlab core, so I want to fix the above errors first.

Thanks

在git协议下,当commit里面有lfs时,可以push, 但是pr会报错

➜ git-repo-lfs-test git:(master) git pr
Uploading LFS objects: 0% (0/1), 0 B | 0 B/s, done.
batch request: invalid character '0' after top-level value
error: failed to push some refs to 'codeup.aliyun.com:606bafcd32fceefde379cc0e/git-repo-lfs-test.git'


[FAILED] ./ master (upload failed: exit status 1)

如果是https协议就可以正常pr。

'git repo sync' get an error of 'is published (but not merged)' after 'git pr'

Run a bash, we get an error of "Error: branch my_patch is published (but not merged)"

#!/bin/bash
SCRIPT_DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd)"
cd $SCRIPT_DIR
REPO=$HOME/bin/repo

set -ex

DIR=`pwd`/test-sync
rm -rf $DIR && mkdir -p $DIR
cd $DIR

git repo init -u [email protected]:alicpp2/test-repo.git
git repo sync -j 32
git repo start my_patch --all
ls -l

cd test_repo1-x
uuid >> INSTALL
git add INSTALL
git commit -m 'a new commit'
echo x | git pr

cd $DIR
rm -rf xtmp
git clone [email protected]:alicpp2/test-repo1.git xtmp/test-repo1
cd xtmp/test-repo1
uuid >> README
git add README
git commit -m 'change readme'
git push origin HEAD:master

cd $DIR/test_repo1-x
git repo sync

image

This situation is very common.
If we work on a patch for weeks, we often need to run 'git pr' to generate the merge request for the reviewer and handle with the challenges, do some code changes and run 'git pr' again. Sometimes we must run 'git repo sync' to rebase the newest code but we get an error.

In our team development-faq, I suggest the solution like this
image
image

It's awful.

got bad ssh_info error

I can not sync the repos by sync today, got errors below

❯ git repo sync
ERROR: bad ssh_info request to 'https://codeup.aliyun.com/ssh_info': Get "https://codeup.aliyun.com/ssh_info": dial tcp: i/o timeout
NOTE: fail to check remote server, you may need to install gerrit hooks by hands
ERROR: fail to load remotes: origin

my git repo version is

❯ git repo --version
git-repo version 0.7.8
git version 2.32.1 (Apple Git-133)
❯ curl https://codeup.aliyun.com/ssh_info
{"type":"agit","version":2}%

Thanks

Using multi-repo manifests without address for review

When dealing with e.g. manifest repositories e.g. here on github, where there is no address for review in the manifest,
you currently get ERROR: bad address for review ''. Its a bit difficult to add try and add remotes to the repo downloaded repositories from git repo sync.

It would be nice if there was a way to easily add remotes to all the repositories checked out,
It seems like perhaps if there was a --remote-manifest-url to git repo init

git repo upload --remote, gives the impression that it only works with --single repositories, (correct?)
--remote string use specific remote for upload (use with --single)

Is there a nice way to make --remote work with multiple repositories, and if not do you think adding something such as --remote-manifest-url would be a good way to do so?

windows系统 linkfile属性有些问题

【系统信息】
版本 Windows 11 企业版 64Bit
版本 22H2
操作系统版本 22621.1992
体验 Windows Feature Experience Pack 1000.22644.1000.0

  1. 目录链接
    【manifest】
    image
    【报错】
    image
    且repo根目录不会创建aa文件夹

  2. 文件链接
    【manifest】
    image
    【报错】
    image
    会创建aa文件夹

<linkfile dest="README.md" src="README.md" /> 这个case是可以成功的

请帮忙看下,多谢!

manifest.xml 中 include 的相对路径计算有问题。

用 repo 时
repo init --no-clone-bundle --repo-url https://gitlab.com/firefly-linux/git-repo.git -u https://gitlab.com/firefly-linux/manifests.git -b master -m rk3288_linux_release.xml

repo sync -c --no-tags
正常。

用 git-repo 时
git-repo init --no-clone-bundle -u https://gitlab.com/firefly-linux/manifests.git -b master -m rk3288_linux_release.xml
git-repo sync -c --no-tags

报错:
FATAL: stat /home/firefly/proj/rk3288_linux_release_v2.5.0a_20230510/.repo/rk3288/rk3288_linux_bsp_release_20220304_v2.5.0a.xml: no such file or directory

How to submit 'git pr' without opening an editor?

version info:
git-repo version 0.7.6
git version 2.19.1.6.gb485710b

I have some regression tests which would update the code, and it's a bit dangerous to git push directly.
Is there a way to submit 'git pr' without opening an editor?

I tried gir pr --no-edit -y, but still opened the editor.

Not all commands from `repo` implemented in `git-repo-go`

git-repo-go could not be used as a drop-in replacement as not all commands from repo implemented yet.

Version: v0.7.8

Help of git-repo-go

Usage:
  git-repo [flags]
  git-repo [command]

Available Commands:
  abandon     Permanently abandon a development branch with --force option
  download    Download and checkout a code review
  filter      Content filter drivers for git
  forall      Run a shell command in each project
  help        Help about any command
  init        Initialize manifest repo in the current directory
  list        List projects and their associated directories
  manifest    Manifest inspection utility
  prune       Prune (delete) already merged topic branches
  start       Start a new branch for development
  status      Show the working tree status
  sync        Update working tree to the latest revision
  upgrade     Check and upgrade git-repo
  upload      Upload changes for code review
  version     Display the version of git-repo

Flags:
      --config string   config file (default is $HOME/.git-repo.yaml)
      --dryrun          dryrun mode
  -h, --help            help for git-repo
  -q, --quiet           quiet mode
      --single          single mode, no manifest
  -v, --verbose count   verbose mode
  -V, --version         Show version

Help of repo

Usage: repo [-p|--paginate|--no-pager] COMMAND [ARGS]

Options:
  -h, --help            show this help message and exit
  --help-all            show this help message with all subcommands and exit
  -p, --paginate        display command output in the pager
  --no-pager            disable the pager
  --color=COLOR         control color usage: auto, always, never
  --trace               trace git command execution (REPO_TRACE=1)
  --trace-python        trace python command execution
  --time                time repo command execution
  --version             display this version of repo
  --show-toplevel       display the path of the top-level directory of the
                        repo client checkout
  --event-log=EVENT_LOG
                        filename of event log to append timeline to
  --git-trace2-event-log=GIT_TRACE2_EVENT_LOG
                        directory to write git trace2 event log to

The most commonly used repo commands are:
  abandon        Permanently abandon a development branch
  branch         View current topic branches
  branches       View current topic branches
  checkout       Checkout a branch for development
  cherry-pick    Cherry-pick a change.
  diff           Show changes between commit and working tree
  diffmanifests  Manifest diff utility
  download       Download and checkout a change
  gitc-delete    Delete a GITC Client.
  gitc-init      Initialize a GITC Client.
  grep           Print lines matching a pattern
  info           Get info on the manifest branch, current branch or unmerged branches
  init           Initialize a repo client checkout in the current directory
  list           List projects and their associated directories
  overview       Display overview of unmerged project branches
  prune          Prune (delete) already merged topics
  rebase         Rebase local branches on upstream branch
  smartsync      Update working tree to the latest known good revision
  stage          Stage file(s) for commit
  start          Start a new branch for development
  status         Show the working tree status
  sync           Update working tree to the latest revision
  upload         Upload changes for code review

git pr --change xxx 不能推送已存在的PR

报错

$ grpr --change 10338772 
ERROR: rename <PROJECT_DIR>/.git/UPLOAD_OPTIONS.d.lock <PROJECT_DIR>/.git/UPLOAD_OPTIONS.d: file exists
Uncommitted changes in mmc-wireless/<REPO_NAME> (did you forget to amend?):
Continue uploading? (y/N) y
Enumerating objects: 40, done.
Counting objects: 100% (40/40), done.
Delta compression using up to 12 threads
Compressing objects: 100% (21/21), done.
Writing objects: 100% (29/29), 3.21 KiB | 1.07 MiB/s, done.
Total 29 (delta 15), reused 0 (delta 0), pack-reused 0
To gitlab.alibaba-inc.com:mmc-wireless/<REPO_NAME>.git
 ! [remote rejected] feature/bar_item_style -> refs/for-review/10338772 (invalid character '<' looking for beginning of value)
error: failed to push some refs to 'gitlab.alibaba-inc.com:mmc-wireless/<REPO_NAME>.git'

----------------------------------------------------------------------
[FAILED] ./              feature/bar_item_style (upload failed: exit status 1)

alias:

$ alias | grep -E 'grcr|grpr'
grcr='git repo download --single'
grpr='git repo upload --single'

在其他分支上通过 grpr 提交了一个PR,然后切新分支再 grcr 拉下来修改,最后用 change 参数更新PR是报错。是内网 gitlab 不支持这样的操作吗?

Use testing.T.TempDir in the tests

We can clean up the tests a bit by starting to use testing.T.TempDir instead of having this in ~20 tests:

tmpdir, err := ioutil.TempDir("", "git-repo")
if err != nil {
log.Fatal(err)
}
defer func(dir string) {
os.RemoveAll(dir)
}(tmpdir)

I would normally just have sent a PR, but testing.T.TempDir was introduced in Go 1.15 and I don't know whether it would be okay to require that compiler version given that go.mod states 1.12 and that .github/workflows/go.yml uses Go 1.14 on Mac OS X. Is there any particular reason Mac OS X builds use an older version than what's tested on Linux?

What exactly does "diff driver" mean?

Hi @jiangxin

As the title described, what does diff dirver mean in Git?
It's the sum of all diff configuration variable like diff.algorithm, diff.context, diff.external, diff.tool, diff.wordRegex etc. ?

Thanks!

Recursive manifest includes use the wrong base path

When the manifest contains recursive inclusions,

default.xml -> foo/bar.xml -> foo/base.xml

the original Repo code uses the directory of the top-level file (default.xml) when resolving the path of the included file, i.e. the inclusion filenames would be according to the example above. This is pretty clear when reading the _ParseManifestXml source code and its include_root parameter.

The code in this module instead joins the directory of the current file with the name from the include element, i.e. in the example above it would incorrectly attempt to open foo/foo/base.xml.

f, err := path.AbsJoin(filepath.Dir(file), i.Name)

维护问题

像这种多仓库的项目是如何维护的?
分支如何划分?比如主仓库需要checkout一个新分支,子仓库的分支如何checkout?还有,清单仓库如何checkout?
还有,发布版本如何走流程?

remote appears to override sshinfo with 'git' user

In proto-agit.go:38 I'm wondering if that is the wrong place for defaulting to the git user.
This appears to override the User field from the ssh_info json with the user "git".
It is also keeping these fallbacks from working in remote.go

Removing that line made it work how I would expect, but perhaps defaulting to the git user is part of the protocol?

'git repo upload' report errors when using latest-ok version

'Latest-ok version' is a version defined by a manifest file with revisions, like the following release.xml:

<manifest>
  <remote name="origin" fetch=".." review="ssh://[email protected]/"></remote>
  <default remote="origin" revision="master" sync-j="8"></default>
  <project name="alicpp2/test-repo1" path="test_repo1" revision="d3c878ac1786e5a6d31b4e8908010580e1f6e584" groups="holo" upstream="master"></project>
  <project name="alicpp2/test-repo2" path="test_repo2" revision="c6d2fa67c86febc802896991414c34c67ea8ee44" groups="holo" upstream="master"></project>
</manifest>

Run the bash to get an error:

#!/bin/bash
SCRIPT_DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd)"
cd $SCRIPT_DIR

set -ex

rm -rf repo && mkdir -p repo
cd repo

git repo init -u [email protected]:alicpp2/test-repo.git -m release.xml
git repo sync -j 32
git repo start my_patch --all

cd test_repo1
touch ZZZ
git add ZZZ
git commit -m 'a test commit'
echo xxx | git repo upload

image

Expect:
Run 'git repo upload' successfully when users work in a repo with latest-ok version.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.