Tampilkan postingan dengan label GitHub. Tampilkan semua postingan
Tampilkan postingan dengan label GitHub. Tampilkan semua postingan

April 24, 2013


Saat sudah membuat proyek pengembangan software menggunakan Go dan akan dipublikasikan ke server penyedia repository Git (seperti github.com, bitbucket.org, atau assembla.com), kita harus menentukan struktur direktori yang baik dari proyek kita. Berdasarkan panduan dari How to Write Go Code (http://golang.org/doc/code.html), tiap proyek kita bagi menjadi beberapa direktori:
  1. src: berisi source code
  2. pkg: berisi paket object code yang telah dikompilasi (pustaka)
  3. bin: binary executable
Jika untuk diri sendiri, barangkali ini sudah selesai. Jika proyek akan kita publikasikan ke git repo, struktur akan sangat berpengaruh. Initialisasi git seharusnya tidak dilakukan di $GOPATH, tetapi di src/. Perhatikan, pada contoh berikut ini $GOPATH adalah root directory dari proyek tempat file test.go berada:


Saya sudah mempunyai account github, dan root directory saya di github adalah http://github.com/bpdp, dengan demikian, saat membuat proyek, misalnya namanya adalah goarangodb, maka proyek tersebut akan berada di http://github.com/bpdp/goarangodb. Untuk kasus seperti ini, source code dari proyek kita sebaiknya diletakkan di $GOPATH/src/github.com/bpdp/goarangodb, sekaligus goarangodb menjadi nama paket. Inisialisasi git dilakukan di direktori $GOPATH/src/github.com/bpdp/goarangodb.

Mengapa harus demikian? Pada saat melakukan go get http://github.com/bpdp/goarangodb, artiffak dari proyek tersebut (source code, README, dll) akan diletakkan di direktori $GOPATH/src/github.com/bpdp/goarangodb. Dengan demikian, kita sebagai pengembang akan mempunyai situasi yang sama dengan deevloper yang meng - go get proyek kita.


Oktober 02, 2012

Git dan Github: Petunjuk Awal

Mengambil dari repo
  • git clone [lokasi]
Contoh:
  • git clone https://github.com/bpdp/buku-cloud-nodejs.git (jika menggunakan https)
  • git clone git://github.com/bpdp/buku-cloud-nodejs.git (jika menggunakan git)
Membuat repo baru di lokal
  • Buat direktori baru
  • Masuk ke direktori baru tersebut
  • Menambahkan semua file:
    • git add -A
  • Commit:
    • git commit -m "First commit - initializing empty repo"
Melihat status repo lokal
    • git status
File baru di repo
  • Menambahkan file
    • git add [file]
  • Commit:
    • git commit -m "Menambahkan file untuk ..."
  • push ke github
Mengedit file
  • Edit file
  • Commit:
    • git commit -m "Pesan"
  • push ke github
Push ke github
  • Menetapkan repo:
    • git remote add origin
      • contoh: git remote add origin https://github.com/bpdp/buku-cloud-nodejs.git
  • Push:
    • git push origin master

Agustus 14, 2012

Working with GitHub and Clojars


This guide is used as a note for myself. If you can benefit from this note, that's fine. Here I just wish to document how I work with GitHub and Clojars. I need to do this since I have my own need for Ring middleware to reload automatically a server without restart whenever a namespace in Ring is modified. The original version was not maintained I think, since it uses Clojure 1.2.0.

GitHub

I forked the ring-reload-modified to my Github account. This can be done easily using step 1 and 2 from https://help.github.com/articles/fork-a-repo (I use only step 1 and 2 since I only want to fork and modified my forked version, not upstream version).

Let's say for this time I just want to edit the README.md and project.clj files. After I edit those files, I just put them in committed state:

[bpdp@bpdp-arch ring-reload-modified]$ git status
# On branch master
# Changes not staged for commit:
#   (use "git add [file]..." to update what will be committed)
#   (use "git checkout -- [file]..." to discard changes in working directory)
#
# modified:   README.md
# modified:   project.clj
#
no changes added to commit (use "git add" and/or "git commit -a")
[bpdp@bpdp-arch ring-reload-modified]$

We can see from the status that it has 2 changes: README.md and project.clj but I haven't commit anything. Here's how to commit:

[bpdp@bpdp-arch ring-reload-modified]$ git commit -a
[master ada41aa] Adjust to latest Clojure version (1.4.0)
 2 files changed, 8 insertions(+), 4 deletions(-)
[bpdp@bpdp-arch ring-reload-modified]$ 

Then it's time to push the committed version to Github repository:

 [bpdp@bpdp-arch ring-reload-modified]$ git push origin master
 Username for 'https://github.com': bpdp
 Password for 'https://bpdp@github.com': 
 Counting objects: 7, done.
 Delta compression using up to 2 threads.
 Compressing objects: 100% (4/4), done.
 Writing objects: 100% (4/4), 721 bytes, done.
 Total 4 (delta 2), reused 0 (delta 0)
 To https://github.com/bpdp/ring-reload-modified.git
    6dfdc5c..ada41aa  master -> master
 [bpdp@bpdp-arch ring-reload-modified]$

Let's see the result in Github profile:



The result in Github project page (I have pushed another commit so the history is different with above).



Clojars

To upload the library, I need to prepare my ssh public key first:

[bpdp@bpdp-arch ring-reload-modified]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/bpdp/.ssh/id_rsa): 
/home/bpdp/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/bpdp/.ssh/id_rsa.
Your public key has been saved in /home/bpdp/.ssh/id_rsa.pub.
The key fingerprint is:
87:fc:8f:35:18:20:2e:8f:73:d2:b5:71:ea:0e:85:01 bpdp@bpdp-arch
The key's randomart image is:
+--[ RSA 2048]----+
|    E            |
|     .           |
|      o .        |
|     . = o       |
|    . o S +      |
|     = o B o     |
|    + = o o o    |
|     + o   + .   |
|       .o . .    |
+-----------------+
[bpdp@bpdp-arch ring-reload-modified]$

The public key should be put into the Clojars first. So, first we need to register by using http://clojars.org/register:



Now, it's time to upload to Clojars:

[bpdp@bpdp-arch ring-reload-modified]$ lein2 jar   
Created /home/bpdp/master/clojure/libs/ring-reload-modified/target/ring-reload-modified-0.1.2.jar
[bpdp@bpdp-arch ring-reload-modified]$ lein2 pom
Wrote /home/bpdp/master/clojure/libs/ring-reload-modified/pom.xml
[bpdp@bpdp-arch ring-reload-modified]$ scp pom.xml target/ring-reload-modified-0.1.2.jar clojars@clojars.org:
Enter passphrase for key '/home/bpdp/.ssh/id_rsa': 
Welcome to Clojars, bpdp!
pom.xml                                                           100% 2672     2.6KB/s   00:00    
ring-reload-modified-0.1.2.jar                                    100% 5328     5.2KB/s   00:00    

Deploying org.clojars.bpdp/ring-reload-modified 0.1.2

Success! Your jars are now available from http://clojars.org/
[bpdp@bpdp-arch ring-reload-modified]$

Now I can use the library that I upload to Clojars:



That's all big guy. Have a happy hacking!