Skip to content

Commit

Permalink
Enable HEAD symref importing the default in gitimport
Browse files Browse the repository at this point in the history
Summary:
Recently, when trying to clone `whatsapp/voip` through Mononoke, we realized that its missing the HEAD symref so if the user clones with `-c init.defaultBranch=<<SOME_NON_MASTER_NAME_HERE>>`, they would get a `remote HEAD refers to nonexistent ref, unable to checkout` error.

To avoid this problem in the future, I am enabling symref HEAD importing by default so if the user forgets to pass the flag, they will still end up importing it.

Reviewed By: singhsrb, mzr

Differential Revision: D54800331

fbshipit-source-id: 2c08dd76262fd5573164f54005d1d2c89dc00139
  • Loading branch information
RajivTS authored and facebook-github-bot committed Mar 13, 2024
1 parent 3367b08 commit da32ae3
Show file tree
Hide file tree
Showing 20 changed files with 27 additions and 27 deletions.
6 changes: 3 additions & 3 deletions eden/mononoke/git/gitimport/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ struct GitimportArgs {
/// Use at your own risk!
#[clap(long)]
generate_bookmarks: bool,
/// If set, will record the HEAD symref in Mononoke for the given repo
/// If set, will skip recording the HEAD symref in Mononoke for the given repo
#[clap(long)]
record_head_symref: bool,
skip_head_symref: bool,
/// When set, the gitimport tool would bypass the read-only check while creating and moving bookmarks.
#[clap(long)]
bypass_readonly: bool,
Expand Down Expand Up @@ -299,7 +299,7 @@ async fn async_main(app: MononokeApp) -> Result<(), Error> {
.await
.context("derive_hg failed")?;
}
if args.record_head_symref {
if !args.skip_head_symref {
let symref_entry = import_tools::read_symref(HEAD_SYMREF, path, &prefs)
.await
.context("read_symrefs failed")?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@

# Import it into Mononoke
$ cd "$TESTTMP"
$ gitimport --record-head-symref "$GIT_REPO" --derive-hg --generate-bookmarks full-repo
$ gitimport "$GIT_REPO" --derive-hg --generate-bookmarks full-repo
* using repo "repo" repoid RepositoryId(0) (glob)
* GitRepo:*repo-git commit 1 of 6 - Oid:* => Bid:* (glob)
* GitRepo:*repo-git commit 2 of 6 - Oid:* => Bid:* (glob)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@

# Import it into Mononoke
$ cd "$TESTTMP"
$ gitimport --record-head-symref "$GIT_REPO" --derive-hg --generate-bookmarks full-repo
$ gitimport "$GIT_REPO" --derive-hg --generate-bookmarks full-repo
* using repo "repo" repoid RepositoryId(0) (glob)
* GitRepo:*repo-git commit 1 of 6 - Oid:* => Bid:* (glob)
* GitRepo:*repo-git commit 2 of 6 - Oid:* => Bid:* (glob)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@

# Import it into Mononoke
$ cd "$TESTTMP"
$ gitimport --record-head-symref "$GIT_REPO" --generate-bookmarks full-repo
$ gitimport "$GIT_REPO" --generate-bookmarks full-repo
* using repo "repo" repoid RepositoryId(0) (glob)
* GitRepo:$TESTTMP/repo-git commit 1 of 7 - Oid:8ce3eae4 => Bid:032cd4dc (glob)
* GitRepo:$TESTTMP/repo-git commit 2 of 7 - Oid:a612a217 => Bid:148f9770 (glob)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

# Import it into Mononoke
$ cd "$TESTTMP"
$ gitimport --record-head-symref "$GIT_REPO" --derive-hg --generate-bookmarks full-repo
$ gitimport "$GIT_REPO" --derive-hg --generate-bookmarks full-repo
* using repo "repo" repoid RepositoryId(0) (glob)
* GitRepo:*repo-git commit 1 of 2 - Oid:* => Bid:* (glob)
* GitRepo:*repo-git commit 2 of 2 - Oid:* => Bid:* (glob)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@

# Import it into Mononoke
$ cd "$TESTTMP"
$ gitimport --record-head-symref "$GIT_REPO" --generate-bookmarks full-repo
$ gitimport "$GIT_REPO" --generate-bookmarks full-repo
* using repo "repo" repoid RepositoryId(0) (glob)
* GitRepo:*repo-git commit 1 of 5 - Oid:* => Bid:* (glob)
* GitRepo:*repo-git commit 2 of 5 - Oid:* => Bid:* (glob)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

# Import it into Mononoke
$ cd "$TESTTMP"
$ gitimport --record-head-symref "$GIT_REPO" --derive-hg --generate-bookmarks full-repo
$ gitimport "$GIT_REPO" --derive-hg --generate-bookmarks full-repo
* using repo "repo" repoid RepositoryId(0) (glob)
* GitRepo:*repo-git commit 1 of 2 - Oid:* => Bid:* (glob)
* GitRepo:*repo-git commit 2 of 2 - Oid:* => Bid:* (glob)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@

# Import it into Mononoke
$ cd "$TESTTMP"
$ gitimport --record-head-symref "$GIT_REPO" --generate-bookmarks full-repo
$ gitimport "$GIT_REPO" --generate-bookmarks full-repo
* using repo "repo" repoid RepositoryId(0) (glob)
* GitRepo:$TESTTMP/repo-git commit 1 of 7 - Oid:8ce3eae4 => Bid:032cd4dc (glob)
* GitRepo:$TESTTMP/repo-git commit 2 of 7 - Oid:a612a217 => Bid:148f9770 (glob)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@

# Import it into Mononoke
$ cd "$TESTTMP"
$ gitimport --record-head-symref "$GIT_REPO" --generate-bookmarks full-repo
$ gitimport "$GIT_REPO" --generate-bookmarks full-repo
* using repo "repo" repoid RepositoryId(0) (glob)
* GitRepo:$TESTTMP/repo-git commit 1 of 7 - Oid:8ce3eae4 => Bid:032cd4dc (glob)
* GitRepo:$TESTTMP/repo-git commit 2 of 7 - Oid:a612a217 => Bid:148f9770 (glob)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

# Import it into Mononoke
$ cd "$TESTTMP"
$ gitimport --record-head-symref "$GIT_REPO" --derive-hg --generate-bookmarks full-repo
$ gitimport "$GIT_REPO" --derive-hg --generate-bookmarks full-repo
* using repo "repo" repoid RepositoryId(0) (glob)
* GitRepo:*repo-git commit 1 of 2 - Oid:* => Bid:* (glob)
* GitRepo:*repo-git commit 2 of 2 - Oid:* => Bid:* (glob)
Expand Down Expand Up @@ -88,7 +88,7 @@

# Import the new commits into Mononoke
$ cd "$TESTTMP"
$ gitimport --record-head-symref "$GIT_REPO" --derive-hg --generate-bookmarks full-repo
$ gitimport "$GIT_REPO" --derive-hg --generate-bookmarks full-repo
* using repo "repo" repoid RepositoryId(0) (glob)
* GitRepo:$TESTTMP/repo-git commit 1 of 4 - Oid:8ce3eae4 => Bid:032cd4dc (already exists) (glob)
* GitRepo:$TESTTMP/repo-git commit 2 of 4 - Oid:e8615d6f => Bid:da93dc81 (already exists) (glob)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

# Import it into Mononoke
$ cd "$TESTTMP"
$ gitimport --record-head-symref "$GIT_REPO" --derive-hg --generate-bookmarks full-repo
$ gitimport "$GIT_REPO" --derive-hg --generate-bookmarks full-repo
* using repo "repo" repoid RepositoryId(0) (glob)
* GitRepo:*repo-git commit 1 of 2 - Oid:* => Bid:* (glob)
* GitRepo:*repo-git commit 2 of 2 - Oid:* => Bid:* (glob)
Expand Down Expand Up @@ -99,7 +99,7 @@
$ git rev-list --objects --all | git cat-file --batch-check='%(objectname) %(objecttype) %(rest)' | sort > $TESTTMP/object_list
# Import it into Mononoke
$ cd "$TESTTMP"
$ gitimport --record-head-symref "$GIT_REPO_ORIGIN" --derive-hg --generate-bookmarks full-repo
$ gitimport "$GIT_REPO_ORIGIN" --derive-hg --generate-bookmarks full-repo
* using repo "repo" repoid RepositoryId(0) (glob)
* GitRepo:*repo-git commit 1 of 2 - Oid:* => Bid:* (glob)
* GitRepo:*repo-git commit 2 of 2 - Oid:* => Bid:* (glob)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@

# Import it into Mononoke
$ cd "$TESTTMP"
$ gitimport --record-head-symref "$GIT_REPO" --generate-bookmarks full-repo
$ gitimport "$GIT_REPO" --generate-bookmarks full-repo
* using repo "repo" repoid RepositoryId(0) (glob)
* GitRepo:*repo-git commit 1 of 3 - Oid:* => Bid:* (glob)
* GitRepo:*repo-git commit 2 of 3 - Oid:* => Bid:* (glob)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

# Import it into Mononoke
$ cd "$TESTTMP"
$ gitimport --record-head-symref "$GIT_REPO" --derive-hg --generate-bookmarks full-repo
$ gitimport "$GIT_REPO" --derive-hg --generate-bookmarks full-repo
* using repo "repo" repoid RepositoryId(0) (glob)
* GitRepo:*repo-git commit 1 of 2 - Oid:* => Bid:* (glob)
* GitRepo:*repo-git commit 2 of 2 - Oid:* => Bid:* (glob)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@

# Import it into Mononoke
$ cd "$TESTTMP"
$ with_stripped_logs gitimport --record-head-symref "$GIT_REPO" --generate-bookmarks --discard-submodules full-repo
$ with_stripped_logs gitimport "$GIT_REPO" --generate-bookmarks --discard-submodules full-repo
using repo "repo" repoid RepositoryId(0)
GitRepo:$TESTTMP/repo-git commit 1 of 3 - Oid:8ce3eae4 => Bid:032cd4dc
GitRepo:$TESTTMP/repo-git commit 2 of 3 - Oid:e8615d6f => Bid:da93dc81
Expand Down
4 changes: 2 additions & 2 deletions eden/mononoke/tests/integration/test-gitimport.t
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

# Import it into Mononoke
$ cd "$TESTTMP"
$ gitimport --record-head-symref "$GIT_REPO" --concurrency 100 --derive-hg full-repo
$ gitimport "$GIT_REPO" --concurrency 100 --derive-hg full-repo
* using repo "repo" repoid RepositoryId(0) (glob)
* GitRepo:*repo-git commit 1 of 1 - Oid:* => Bid:* (glob)
* Hg: Sha1(8ce3eae44760b500bf3f2c3922a95dcd3c908e9e): HgManifestId(HgNodeHash(Sha1(*))) (glob)
Expand Down Expand Up @@ -137,7 +137,7 @@
* Nothing to import for repo *repo-git. (glob)

# Also check that a readonly import works
$ gitimport "$GIT_REPO" --with-readonly-storage=true --derive-hg full-repo
$ gitimport "$GIT_REPO" --with-readonly-storage=true --derive-hg --skip-head-symref full-repo
* using repo "repo" repoid RepositoryId(0) (glob)
* GitRepo:*repo-git commit 1 of 2 - Oid:* => Bid:* (glob)
* GitRepo:*repo-git commit 2 of 2 - Oid:* => Bid:* (glob)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Go back to the master branch

# Import it into Mononoke
$ cd "$TESTTMP"
$ gitimport --record-head-symref "$GIT_REPO_ORIGIN" --derive-hg --generate-bookmarks full-repo &> /dev/null
$ gitimport "$GIT_REPO_ORIGIN" --derive-hg --generate-bookmarks full-repo &> /dev/null

# Start up the Mononoke Git Service
$ mononoke_git_service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

# Import it into Mononoke
$ cd "$TESTTMP"
$ gitimport --record-head-symref "$GIT_REPO" --derive-hg --generate-bookmarks full-repo
$ gitimport "$GIT_REPO" --derive-hg --generate-bookmarks full-repo
* using repo "repo" repoid RepositoryId(0) (glob)
* GitRepo:*repo-git commit 1 of 2 - Oid:* => Bid:* (glob)
* GitRepo:*repo-git commit 2 of 2 - Oid:* => Bid:* (glob)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

# Import it into Mononoke
$ cd "$TESTTMP"
$ gitimport --record-head-symref "$GIT_REPO" --derive-hg --generate-bookmarks full-repo
$ gitimport "$GIT_REPO" --derive-hg --generate-bookmarks full-repo
* using repo "repo" repoid RepositoryId(0) (glob)
* GitRepo:*repo-git commit 1 of 2 - Oid:* => Bid:* (glob)
* GitRepo:*repo-git commit 2 of 2 - Oid:* => Bid:* (glob)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

# Import it into Mononoke
$ cd "$TESTTMP"
$ gitimport --record-head-symref "$GIT_REPO" --derive-hg --generate-bookmarks full-repo &> /dev/null
$ gitimport "$GIT_REPO" --derive-hg --generate-bookmarks full-repo &> /dev/null

# Start up the Mononoke Git Service
$ mononoke_git_service
Expand Down Expand Up @@ -71,7 +71,7 @@

# Import the newly added commits to Mononoke
$ cd "$TESTTMP"
$ gitimport --record-head-symref "$GIT_REPO_ORIGIN" --derive-hg --generate-bookmarks full-repo &> /dev/null
$ gitimport "$GIT_REPO_ORIGIN" --derive-hg --generate-bookmarks full-repo &> /dev/null
# Pull the Git repo from Mononoke
$ cd $REPONAME
$ git_client pull $MONONOKE_GIT_SERVICE_BASE_URL/$REPONAME.git &> /dev/null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

# Import it into Mononoke
$ cd "$TESTTMP"
$ gitimport --record-head-symref "$GIT_REPO" --derive-hg --generate-bookmarks full-repo &> /dev/null
$ gitimport "$GIT_REPO" --derive-hg --generate-bookmarks full-repo &> /dev/null

# Start up the Mononoke Git Service
$ mononoke_git_service
Expand Down Expand Up @@ -69,7 +69,7 @@

# Import the newly added commits to Mononoke
$ cd "$TESTTMP"
$ gitimport --record-head-symref "$GIT_REPO_ORIGIN" --derive-hg --generate-bookmarks full-repo &> /dev/null
$ gitimport "$GIT_REPO_ORIGIN" --derive-hg --generate-bookmarks full-repo &> /dev/null
# Pull the Git repo from Mononoke
$ cd $REPONAME
$ git_client pull $MONONOKE_GIT_SERVICE_BASE_URL/$REPONAME.git &> /dev/null
Expand Down

0 comments on commit da32ae3

Please sign in to comment.