Frage

Ich habe in Magit Probleme mit Schritt Nr. 5 und Schritt Nr. 7 zum Erstellen eines neuen Repositorys.Falls vorhanden, was sind (bitte) die interaktiven Funktionsäquivalente für die Schritte 5 und 7?

Wenn es keine interaktiven Äquivalente gibt, muss ich vermutlich meine eigenen Shell-Befehlsfunktionen schreiben – es sei denn natürlich, jemand möchte sie zuerst ausprobieren.:) :)


ERSTELLEN -- BEFEHLSZEILENREZEPT

1.  $  touch README.md

2.  $  /usr/local/git/bin/git init

3.  $  /usr/local/git/bin/git add .

4.  $  /usr/local/git/bin/git commit -m "First commit."

5.  $  curl -u 'USERNAME' https://api.github.com/user/repos -d '{"name":"REPO-NAME"}'

6.  $  Enter password:  PASSWORD

7.  $  /usr/local/git/bin/git remote add origin git@github.com:USERNAME/REPO-NAME.git

8.  $  /usr/local/git/bin/git push origin master

NOTIZ:Die Schritte 5 und 6 können (falls gewünscht) wie folgt kombiniert werden: curl -u 'USERNAME':'PASSWORD' https://api.github.com/user/repos -d '{"name":"REPO-NAME"}'


LÖSCHEN -- BEFEHLSZEILENREZEPT

NOTIZ:Das Benutzertoken muss haben delete_repo Behörde.Siehe Dokumentzeichenfolge von delete-remote-repo.

curl -X DELETE -H 'Authorization: token xxx' https://api.github.com/repos/USERNAME/REPO-NAME

BEARBEITEN (13. April 2014):Erster Arbeitsentwurf.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; http://stackoverflow.com/q/23039562/2112489

(defvar git-username nil
 "The username of the Github account.")
(make-variable-buffer-local 'git-username)

(defvar git-password nil
 "The password of the Github account.")
(make-variable-buffer-local 'git-password)

(defvar git-token nil
 "The applicable token of the Github account.")
(make-variable-buffer-local 'git-token)

(defvar repo-name nil
 "The name of the Github repository.")
(make-variable-buffer-local 'repo-name)

(defun create-remote-repo ()
"Execute this function from the root directory of the repo -- e.g., in dired-mode."
(interactive)
  (setq git-username (read-string "Name of User:  "))
  (setq git-password (read-string "Password of User:  "))
  (setq repo-name (read-string "Name of Repository:  "))
  (set-process-sentinel
    (start-process
      "repo-process"
      "*REPO*"
      "/usr/bin/touch"
      "README.md")
    (lambda (p e) (when (= 0 (process-exit-status p))
      (set-process-sentinel
        (start-process
          "repo-process"
          "*REPO*"
          "/usr/local/git/bin/git"
          "init")
        (lambda (p e) (when (= 0 (process-exit-status p))
          (set-process-sentinel 
            (start-process
              "repo-process"
              "*REPO*"
              "/usr/local/git/bin/git"
              "add"
              ".")
            (lambda (p e) (when (= 0 (process-exit-status p))
              (set-process-sentinel 
                (start-process
                  "repo-process"
                  "*REPO*"
                  "/usr/local/git/bin/git"
                  "commit"
                  "-m"
                  "\"First commit.\"")
                (lambda (p e) (when (= 0 (process-exit-status p))
                  (set-process-sentinel
                    (start-process
                      "repo-process"
                      "*REPO*"
                      "/usr/bin/curl"
                      "-u"
                      (concat
                        git-username
                        ":"
                        git-password)
                      "https://api.github.com/user/repos"
                      "-d"
                      (concat
                        "\{\"name\":\""
                        repo-name
                        "\"\}"))
                    (lambda (p e) (when (= 0 (process-exit-status p))
                      (set-process-sentinel 
                        (start-process
                          "repo-process"
                          "*REPO*"
                          "/usr/local/git/bin/git"
                          "remote"
                          "add"
                          "origin"
                          (concat
                            "git@github.com:"
                            git-username
                            "/"
                            repo-name
                            ".git"))
                        (lambda (p e) (when (= 0 (process-exit-status p))
                          (set-process-sentinel 
                            (start-process
                              "repo-process"
                              "*REPO*"
                              "/usr/local/git/bin/git"
                              "push"
                              "origin"
                              "master")
                            (lambda (p e) (when (= 0 (process-exit-status p))
                              (if (eq major-mode 'dired-mode)
                                (revert-buffer))
                              (display-buffer (get-buffer "*REPO*") nil)
                              (message
                                "Repository `%s` has been successfully created!"
                                repo-name) ))))))))))))))))))))))

(defun delete-remote-repo ()
"To delete a repository, the user must have token `delete_repo` authorization.
Visit your `Account Settings` | `Applications`.  Either edit a current token
or generate a new token with `delete_repo` authorization, and write down the
token in a safe place because it is only displayed one time."
(interactive)
  (setq git-username (read-string "Name of User:  "))
  (setq repo-name (read-string "Name of Repository:  "))
  (setq git-token (read-string "Token (with `delete_repo` authority):  "))
  (set-process-sentinel
    (start-process "delete-repo-process" "*DELETE-REPO*"
      "/usr/bin/curl"
      "-X"
      "DELETE"
      "-H"
      (concat
        "Authorization: token "
        git-token
        )
      (concat
        "https://api.github.com/repos/"
        git-username
        "/"
        repo-name))
    (lambda (p e) (when (= 0 (process-exit-status p))
      (display-buffer (get-buffer "*DELETE-REPO*") nil)
        (if (with-current-buffer (get-buffer "*DELETE-REPO*")
              (equal (buffer-size) 0))
          (progn
            (with-current-buffer (get-buffer "*DELETE-REPO*")
              (insert "It looks like everything worked okay."))
            (message "Repository `%s` has been successfully deleted!" repo-name))
          (message "OOOPS!!!  Something went wrong in the deletion process!") )))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
War es hilfreich?

Lösung

Magit stellt keine Befehle zur Interaktion mit Githhb bereit.Sie müssen Ihren eigenen Befehl schreiben call-process Und curl, oder mit gh.el, das die Github-API umschließt.

Um eine neue Fernbedienung hinzuzufügen, geben Sie ein M a im Magit-Statuspuffer.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top