Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ascii_binder not stashing all changes before moving to another branch #152

Open
iranzo opened this issue Sep 18, 2019 · 2 comments
Open

Comments

@iranzo
Copy link

iranzo commented Sep 18, 2019

Environment:

  • Fedora 30
 iranzo   release-0.17  …  syseng  kube  user-guide  gem list|grep ascii
ascii_binder (0.1.14)
asciidoctor (1.5.6.1)

I've wrote a script that pregenerates all local branches and updates the distro map so that asciibinder can create docs for all releases

#!/bin/bash
# Description: This script generates a distro_map.yml with mentions to each release to build

releases() {
curl  "https://api.github.com/repos/kubevirt/kubevirt/tags" 2>&1|grep "name"|grep "v[0-9]*\.[0-9]*\.0\""|awk -F ":" '{print $2}'|tr -d '",v'|cut -d "." -f 1-2
}

gen_distromap() {
  {
  # Pregenerate local branches for ascii_binder to work
  git fetch --all
  for REL in $(releases);
  do
    git branch release-$REL --track origin/release-$REL
  done

  cat << EOF > _distro_map.yml
---
kubevirt-community:
  name: KubeVirt
  author: KubeVirt Documentation Team
  site: community
  site_name: Documentation
  site_url: https://kubevirt.io/docs
  branches:
    master:
      name: Latest
      dir: latest
EOF

  # Prefill distro_map with releases
  for REL in $(releases);
  do
    echo "    release-$REL:" >> _distro_map.yml
    echo "      name: \"$REL\"" >> _distro_map.yml
    echo "      dir: \"$REL\"" >> _distro_map.yml
  done
  }
}

gen_distromap

When executed:

 iranzo   allreleases  …  syseng  kube  user-guide  git diff
 iranzo   allreleases  …  syseng  kube  user-guide  ./scripts/
.history/               generate_distro_map.sh  
 iranzo   allreleases  …  syseng  kube  user-guide  ./scripts/generate_distro_map.sh 
Fetching origin
X11 forwarding request failed on channel 0
Fetching upstream
X11 forwarding request failed on channel 0
error: the requested upstream branch 'origin/release-0.21' does not exist
hint: 
hint: If you are planning on basing your work on an upstream
hint: branch that already exists at the remote, you may need to
hint: run "git fetch" to retrieve it.
hint: 
hint: If you are planning to push out a new local branch that
hint: will track its remote counterpart, you may want to use
hint: "git push -u" to set the upstream config as you push.
error: the requested upstream branch 'origin/release-0.20' does not exist
hint: 
hint: If you are planning on basing your work on an upstream
hint: branch that already exists at the remote, you may need to
hint: run "git fetch" to retrieve it.
hint: 
hint: If you are planning to push out a new local branch that
hint: will track its remote counterpart, you may want to use
hint: "git push -u" to set the upstream config as you push.
fatal: A branch named 'release-0.19' already exists.
fatal: A branch named 'release-0.18' already exists.
fatal: A branch named 'release-0.17' already exists.
fatal: A branch named 'release-0.16' already exists.
fatal: A branch named 'release-0.15' already exists.
fatal: A branch named 'release-0.14' already exists.
 iranzo   allreleases  …  syseng  kube  user-guide  asciibinder package
Building all distributions.
WARN: The following branches do not exist in your local git repo:
- release-0.20
- release-0.21
The build will proceed but these branches will not be generated.
CHANGING TO BRANCH 'master'
WARN: Branch master includes 30 files that are not referenced in the _topic_map.yml file. Set logging to 'debug' for details.
Building KubeVirt for branch 'master'
CHANGING TO BRANCH 'release-0.19'
WARN: Branch release-0.19 includes 30 files that are not referenced in the _topic_map.yml file. Set logging to 'debug' for details.
Building KubeVirt for branch 'release-0.19'
CHANGING TO BRANCH 'release-0.18'
WARN: Branch release-0.18 includes 30 files that are not referenced in the _topic_map.yml file. Set logging to 'debug' for details.
Building KubeVirt for branch 'release-0.18'
CHANGING TO BRANCH 'release-0.17'
WARN: Branch release-0.17 includes 30 files that are not referenced in the _topic_map.yml file. Set logging to 'debug' for details.
Building KubeVirt for branch 'release-0.17'
CHANGING TO BRANCH 'release-0.16'
Error: Could not generate docs:
Git::GitExecuteError: git '--git-dir=/home/iranzo/DEVEL/RH/syseng/kube/user-guide/.git' '--work-tree=/home/iranzo/DEVEL/RH/syseng/kube/user-guide' checkout 'release-0.16'  2>&1:error: Your local changes to the following files would be overwritten by checkout:
	_distro_map.yml
Please commit your changes or stash them before you switch branches.
Aborting at
    /usr/share/gems/gems/git-1.4.0/lib/git/lib.rb:956:in `command'
    /usr/share/gems/gems/git-1.4.0/lib/git/lib.rb:646:in `checkout'
    /usr/share/gems/gems/git-1.4.0/lib/git/base.rb:306:in `checkout'
    /usr/share/gems/gems/git-1.4.0/lib/git/branch.rb:28:in `checkout'
    /usr/share/gems/gems/ascii_binder-0.1.14/lib/ascii_binder/engine.rb:34:in `git_checkout'
    /usr/share/gems/gems/ascii_binder-0.1.14/lib/ascii_binder/engine.rb:301:in `block in generate_docs'
    /usr/share/gems/gems/ascii_binder-0.1.14/lib/ascii_binder/engine.rb:292:in `each'
    /usr/share/gems/gems/ascii_binder-0.1.14/lib/ascii_binder/engine.rb:292:in `generate_docs'
    /usr/share/gems/gems/ascii_binder-0.1.14/bin/asciibinder:17:in `call_generate'
    /usr/share/gems/gems/ascii_binder-0.1.14/bin/asciibinder:320:in `<top (required)>'
    /usr/bin/asciibinder:23:in `load'
    /usr/bin/asciibinder:23:in `<main>'.
Try --help for help.

It has created the docs for several branches, but then it complains with one of them because of the _distro_map.yml where it should have been read at start and then squashed according to documentation, but still shows the 'diff' that my initial script generated:

diff --git a/_distro_map.yml b/_distro_map.yml
index 4812d65..c8e2c82 100644
--- a/_distro_map.yml
+++ b/_distro_map.yml
@@ -9,6 +9,21 @@ kubevirt-community:
     master:
       name: Latest
       dir: latest
+    release-0.21:
+      name: "0.21"
+      dir: "0.21"
+    release-0.20:
+      name: "0.20"
+      dir: "0.20"
+    release-0.19:
+      name: "0.19"
+      dir: "0.19"
+    release-0.18:
+      name: "0.18"
+      dir: "0.18"
+    release-0.17:
+      name: "0.17"
+      dir: "0.17"
     release-0.16:
       name: "0.16"
       dir: "0.16"

Shouldn't it have been deleted as documentation states and have avoided this issue?

@iranzo
Copy link
Author

iranzo commented Sep 19, 2019

@nhr @Fryguy @bexelbie any hint on the issue above?

Thanks!

@bexelbie
Copy link
Contributor

@iranzo I am no longer actively using this project as Fedora Docs has migrated to using Antora. Therefore this comment is from memory.

It looks like you need to manually commit your updated distro_map.yml in master before you run asciibinder package. This seems to be the issue. Asciibinder, iirc, doesn't handle uncommitted config files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants